We are using the Powershell BizTalk Adapter when deploying our BizTalk solution.
And since we depend on a lot of external services and expose som WCF-services as well, we might as well do a quick test to see if the respond properly. Even a simple check to see if the URL responds with HTTP 200-OK will catch a lot of configuration and setup related errors.
The following script will iterate through all WCF receive and send port and try a simpe HTTP get. Perfect as the last step of any BizTalk deployment :-)
function GetStatusCodeFromURL
{
param([string]$serviceName,[string]$url)
try
{
Write-Host "$serviceName => " -NoNewline
$req=[system.Net.HttpWebRequest]::Create($url);
$res = $req.getresponse();
$stat = $res.statuscode;
$res.Close();
if ($stat -eq "OK")
{
Write-Host "$stat" -ForegroundColor:Green
}
else
{
Write-Host "$stat" -ForegroundColor:Red
}
}
catch [System.Exception]
{
$exceptionMessage = $url + ": " + $_.Exception.Message
Write-Host $exceptionMessage -ForegroundColor:Red
}
}
Write-Host "Testing HTTP send- and receiveports" -ForegroundColor:Green
## All receive locations
foreach ($bizApplication in Get-ChildItem "BizTalk:\Applications" | Where-Object {$_.Status -ne "NotApplicable"})
{
$bizApplicationName = $bizApplication.Name
foreach ($bizReceiveLocation in Get-ChildItem "BizTalk:\Applications\$bizApplicationName\Receive Locations" | Where-Object {$_.Address.EndsWith(".svc")})
{
$desc = $bizApplicationName + ": " + $bizReceiveLocation.Name
GetStatusCodeFromURL $desc "http://localhost" + $bizReceiveLocation.Address
}
foreach ($bizSendPort in Get-ChildItem "BizTalk:\Applications\$bizApplicationName\Send Ports" | Where-Object {$_.IsTwoWay -eq $true})
{
$desc = $bizApplicationName + ": " + $bizSendPort.Name
GetStatusCodeFromURL $desc $bizSendPort.PrimaryTransportAddress
}
}
Christian Staerk
8f622f1f-042d-4e2a-a836-f4cd2fbfc5ec|0|.0
BizTalk Server, Sharepoint Server