Tuesday, 8 November 2011

WCF, OneWay and BizTalk

In WCF there is an option in your contract to markup as an OneWay method like this:


        [OperationContract(IsOneWay=true)]

You will get the following error when you try to send a message from BizTalk to this WCF Service:
Details:"System.ServiceModel.CommunicationException: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
The problem with this is that BizTalk can't consume the WCF service as it only supports the Request/Reply pattern of WCF, so what options do you have when you have a fire-and-forget WCF service that you want to consume from BizTalk:
  1. Change the attribute in your WCF Service, so the "IsOneWay" is set to "false". This is only an option if you have control over your WCF Service
  2. Create a wrapper around the WCF Service that wraps you service. This blog post is one way to do it: http://www.pvle.be/2008/12/calling-one-way-wcf-service-with-biztalk-wcf-adapter-part-2/
You should go for the solution it the order listed above. Other possible solutions that I haven't tried, but might work (could be fun to try out at some point in time):
  1. Implement a custom behavior (could maybe also be a solution as you hook into the WCF model, but I am not sure if it will work)
  2. Implement your own WCF adapter using the WCF SDK (A lot of work, should work as you have complete control over the message flow)
Random posts: