Thursday, December 30, 2010

How to ‘loosely couple’ an orchestration to a WCF webservice

Consider the following scenario:

I have an orchestration, which is activated by a Direct receive port, i.e. the orchestration is activated when a certain message (of the type the receive shape filters on) is written to the messagebox. At the end of the orchestration, the output message is sent to a Direct send port, i.e. the message is written to the messagebox.

Now I define a request-response WCF webservice, and what I want is that a message sent to this webservice is picked up by the orchestration and obviously the result message from the orchestration should be sent through the webservice again.

The first steps in this plan are easy: create the orchestration, create a webservice using the BizTalk WCF Service Publishing Wizard, deploy it all and go! But alas, there will be a routing failure… BizTalk doesn’t know where to send the result message from the orchestration.

So how do we tell BizTalk the result message should be send back to the webservice? To cut a long story short, we need a Message Assignment on the result message with this code:
Message_Out(*) = Message_In(*);
Message_Out(BTS.RouteDirectToTP) = true;
Message_Out(BTS.IsRequestResponse) = true;

and on the send shape we need a Correlation Set with these properties:
That’s all there’s to it!

If you want the long explanation and the ‘why’ of it all, check out Bram Veldhoen’s blog, which perfectly describes it in full detail. So no need for me to go through all that effort…

Configuring IIS to work with WCF services

The first time you’ll try to access a WCF service, you may get a ‘HTTP Error 404.3 - Not Found’ error. This can be caused by WCF not being installed properly yet. To install WCF, do the following:

At a command prompt, type the following commands:
cd c:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\

ServiceModelReg –i

For more background, check out this blog:

Visual Studio 2008 doesn’t know a BizTalk project

If you have a new Visual Studio 2008 installation, or updated it in any way, you may find that adding a new BizTalk project will fail. The solution is simple: in the registry, change key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{FAE04EC0-301F-11d3-BF4B-00C04F79EFBC}] from ‘csproj’ to ‘csproj;btproj’. Somehow this key gets reset every time the Visual Studio installation is changed...