Automatic testing of WCF Receive and send ports

28. November 2011

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  

BizTalk Server, Sharepoint Server

Using powershell to query shared ressources

11. November 2011

While testing settings in a development enviroment, i needed a simple way to reflect and discover shared runtime ressources, with powershell of cause!

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Solutions.BTARN.Shared”)

$runtimeValue = [Microsoft.Solutions.BTARN.Shared.RuntimeGlobal]::DataDbConnectionString

Write-Host $runtimeValue

easy  ;)

 


Michael Høtoft  

Sharepoint Server

IIS 32 bit mode

9. November 2011

Tyring to install sharepoint services 3.0 for a BizTalk 2009 BAM feature, I ran into an error regarding IIS running in 32 bit emulation mode. To change this use the following command:

CScript "%SystemDrive%\InetPub\AdminScripts\adsutil.vbs" set w3svc/AppPools/Enable32bitAppOnWin64 0

And perform an iisreset.


Michael Høtoft  

BizTalk Server, Sharepoint Server

Manually adding the BizTalk Powershell Provider extension

6. June 2011

After trying a gazillion times to install the BizTalk powershell adapter (without errors) and being unable to uninstall it. I was forced to look for alternate solutions.

I came up with the idea of manually registering the extension based upon the installed Dll's.

And it worked like a charm:

 

PS C:\Program Files (x86)\BizTalkFactory PowerShell Provider> 

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil

installutil .\BizTalkFactory.PowerShell.Extensions.dll

Add-PSSnapin -Name BizTalkFactory.PowerShell.Extensions

get-PSsnapin -registered

expected result :

Name        : BizTalkFactory.PowerShell.Extensions
PSVersion   : 2.0
Description : Windows PowerShell CmdLets and Provider for Microsoft Biztalk Serv

 

Addition : Elevated priveledges is not the issue. But it's definently worth trying before anything else, if you tend to forget it from time to time like I do ;)

 


Michael Høtoft  

BizTalk Server, Sharepoint Server ,

Add XML comment via Powershell

6. June 2011

Just a quick post regarding adding comments to XML files in powershell. ie. Build versions in config files etc.

 

 

param([string]$configfile="C:\Users\mh0030\Documents\PowerShell\CommentTestFile.xml", [string]$comment="My default comment")

$doc = [xml](get-content $configfile)

$root = $doc.SelectSingleNode("/MyRoot")
$comment = $doc.CreateComment($comment)
$doc.InsertBefore($comment,$root)
$outFile = (Split-Path -Parent $configfile) + "\outfile.xml"

$doc.save($outFile)


The two important parts are; the navigator element, in this case $root as selected by "/MyRoot" and the other part is how you want to insert the comment. InsertAfter, InsertBefore, AppendChild.
See the .net documentation for further details here : http://msdn.microsoft.com/en-us/library/system.xml.xmldocument_methods.aspx

 


Michael Høtoft  

Sharepoint Server ,

BizTalk Powershell slide deck from DBUG May 2011

6. May 2011

Attached is the BizTalk powershell slide deck, that I used at the Danish BizTalk User Group garthering

BizTalk and Powershell.pptx (448,12 kb)


Michael Høtoft  

BizTalk Server, News, Sharepoint Server ,

Customizing BizTalk Binding files - missing filters

9. March 2011

While creating autogenerated binding files through Excel and Powershell i discovered that my send port filthers were missing.

 

Thomas Restrepo could elaborate on why visual studios was messing up my template binding file, and also why BizTalk Import binding seems to be a bit delicate ;)

Find details here : http://winterdom.com/2008/06/biztalkfiltersnotgettingimported, and thx Thomas, saved my for hours if not days of trying to guess what was wrong.

 

BR

 


Michael Høtoft  

BizTalk Server, Sharepoint Server, Workflow ,

SharePoint 2010 Solution Architecture

14. July 2010

 

The last copuple of months I have been building a SharePoint 2010 solution using SPMetal (LinqToSharePoint) and the SharePoint Lists as model layer.

 

 

The cool part is, that it can be deployed as one SharePoint sitedefintion. No need to create and connect to seperate applikation databases. It's all SharePoint ;)

the not so cool part is, that we rely entirely on the SharePoint engine to handle the model layer. Depending on your code and requirements performance is a potentiel issue. So remember to do early technological proofs if you try to build it this way.

 

 


Michael Høtoft  

Sharepoint Server , ,

Great SPMetal ressource

14. April 2010

 

Stephane Eyskens has created a very detailed and extensive article regarding SPMetal and very importantly also the reason behind some of the build-inn limitations.

http://stephaneey.developpez.com/tutoriel/sharepoint/sp2010linqen/

A must read for any who is using or considering using SPMetal for SharePoint 2010


Michael Høtoft  

Sharepoint Server

Writing Unit Tests with SPMetal in VST2010 RC for SharePoint 2010

12. April 2010

 

I really hope today’s release of VST2010 will solve this issue. In my current setup, VST2010 RC and SharePoint 2010 beta its not really possible building Unit Test against SPMetal.

I have a simple DomainModel and DomainModelTest project.

The DomainModel project contains the SPMetal autogenerated MySystem.cs file.

The DomainModelTest project contains a unit test to test the DomainModel as expected.

 

The test :

[TestMethod()]
       public void DataleverandoerTest()
       {
           ResourceManager resMgr = new ResourceManager("DomainModelTest.TestSettings", Assembly.GetExecutingAssembly());

           string requestUrl = resMgr.GetString("weburl"); // TODO: Initialize to an appropriate value
           IUSystemDataContext target = new IUSystemDataContext(requestUrl); // TODO: Initialize to an appropriate value
           EntityList<Item> actual;
           actual = target.Dataleverandoer;
           Assert.Inconclusive("Verify the correctness of this test method.");

 

The immidiate error :

Test method DomainModelTest.IUSystemDataContextTest.DataleverandoerTest threw exception:
System.IO.FileNotFoundException:

 

Srini Sistla's Blog

 

Srini Sistla found out that this happens because the test project is running under .net Framework 4.0. Thanks Srini it could have had me blocked for hours ;)

http://codename-srini.blogspot.com/2010/03/error-systemiofilenotfoundexception-was.html

 

The simple solution: #FAIL

Change the framework to 3.5… FAIL.  IT CANT BE DONE IN VST2010 RC !! And its a well know bug : https://connect.microsoft.com/VisualStudio/feedback/details/483939/unable-to-change-target-framework-version-on-unit-test-projects

 

Today is 2010 release day. I really hope it’s fixed and will get back to Y’all. Otherwise its back to the good old NUnit or similar.


Michael Høtoft  

Sharepoint Server, Visual Studio 2010