Compartir a través de


WCF One Way Services and BizTalk WCF Adapter

The WCF Services can be defined with a one-way contract, request-reply or a duplex contract. The default behavior of a service operation is the request-reply pattern. In a request-reply pattern, the client waits for the reply message, even if the service operation is represented in code as a void method. With a one-way operation, only one message is transmitted. The receiver does not send a reply message, nor does the sender expect one. For a one-way service the IsOneWay attribute is set to true. For a request-reply service the value for IsOneWay attribute is set to the default value, false.

 

Here is an example of a contract with one-way operations:

    [ServiceContract(Namespace="https://Microsoft.ServiceModel.Samples")]

    public interface ICalculator

    {

        [OperationContract(IsOneWay=true)]

        void Add(double n1, double n2);

    }

 

When a One Way WCF Service is called from the BizTalk Orchestration with BizTalk WCF Send Adapter using a particular binding, the BizTalk throws the following error and suspends the orchestration:

 

"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"

 

BizTalk WCF Adapter does NOT support “pure” one-way services. In order for WCF Services to work in BizTalk Server using BizTalk WCF Adapter, the Service Provider must define contracts using request-reply pattern and in cases where no response is necessary, set the response to be of type “void”. All WCF clients and services that communicate with the BizTalk WCF adapter are expected to be two way, with the exception of services that use NetMsmqQueueBinding. For every other binding, BizTalk expects a void response back from the service (or a non-void response if using a two-way send port). This is so that BizTalk knows when to delete the message from the Message Box and thereby ensuring no message loss.

 

Here is an example of a request-response void contract that can be used within a BizTalk One-Way Send Port.

 

    [ServiceContract(Namespace="https://Microsoft.ServiceModel.Samples")]

    public interface ICalculator

    {

        [OperationContract]

        void Add(double n1, double n2);

    }

 

In channel talk, if the WCF Binding supports both IRequestChannel (two-way) and IOutputChannel (one-way), BizTalk WCF Send Adapter chooses IRequestChannel. Similarly, BizTalk WCF Receive Adapter uses IReplyChannel (two-way) instead of IInputChannel (one-way). The same behavior is applicable to sessionful and duplex channels as well.

 

Hence, the adapters should make the generated operations contract request-reply (with void reply in case of empty response) for it to work in BizTalk Server. If there is a real need for “Fire-and-forget” operation, the adapter can of course have it, just remember that it won’t work in BizTalk.

Comments

  • Anonymous
    May 30, 2007
    Both of your interface looks same. may be a typing mistake.. you can have this modified. Also .. so we can't have shoot and forget calls to WCF services from WCF adapters.We have to wait for WCF Service to complete..

  • Anonymous
    May 09, 2008
    I've actually found the opposite seems to be true for the WCF NetTcp receive adapter. When I define a two-way service and send it to BizTalk via a WCF NetTcp receive port, the calling client hangs waiting for a response. If I define a one-way service and send it to the same receive port, it works just fine. I haven't tested with any of the other WCF receive adapters; I'll do some investigation this weekend.