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:
BTS.CorrelationToken,BTS.EpmRRCorrelationToken,BTS.IsRequestResponse,BTS.ReqRespTransmitPipelineID,BTS.RouteDirectToTP
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…

No comments:

Post a Comment