Invoking TCP-Hosted WCF Services using BizTalk Server R2

One of the great features that we (TwoConnect) accomplished with the WSE 3.0 adapter for BizTalk Server was the support for non-HTTP transports. The capability of decoupling the Web Services interaction of the transport used for the communication opens a new set of possibilities for BizTalk Server processes.

This transport independence concept comes naturally in WSE 3.0 and is being taken to another level in the Windows Communication Foundation (WCF) channel model. As part of BizTalk Server R2 Microsoft provides a set of WCF adapters that uses a common set of WCF bindings. Among them the WCF-NetTcp adapter abstracts the interactions with WCF services that communicate using TCP as transport protocol. Alternatively we can use the WCF-Custom adapter which also understands the WCF NetTcp Binding

Let’s take the following WCF service as an example:

  

[ServiceContract()]

public interface IMathService

{

  [OperationContract]

  int Add(int param1, int param2);

}

  

public class MathService: IMathService

{

public int Add(int param1, int param2)

{

  return param1 + param2;

}

}

  

This WCF Service is associated with the following binding that declares the use of Tcp as the transport protocol of the WCF Service endpoint. The alternative endpoint is just used in order to have access to the Service description (WSDL).

  

                                     

<configuration>

      <system.serviceModel>

            <services>

                  <service name="MathService.MathService"

                               behaviorConfiguration="CalculatorServiceBehavior">

                        <host>

                              <baseAddresses>

                                    <add baseAddress="http://localhost:8000/servicemodelsamples/service"/>

                              </baseAddresses>

                        </host>

                        <!-- this endpoint is exposed at: net.tcp://localhost:9000/servicemodelsamples/service  -->

                        <endpoint address="net.tcp://localhost:9000/servicemodelsamples/service"

                                      binding="netTcpBinding"

                                      bindingConfiguration="Binding1"

                                      contract="MathService.IMathService" />

                        <!-- the mex endpoint is explosed at http://localhost:8000/ServiceModelSamples/service/mex -->

                        <endpoint address="mex"

                                      binding="mexHttpBinding"

                                      contract="IMetadataExchange" />

                  </service>

            </services>

            <bindings>

                  <netTcpBinding>

                        <binding name="Binding1"

                                     closeTimeout="00:01:00"

                                     openTimeout="00:01:00"

                                     receiveTimeout="00:10:00"

                                     sendTimeout="00:01:00"

                                     transactionFlow="false"

                                     transferMode="Buffered"

                                     transactionProtocol="OleTransactions"

                                     hostNameComparisonMode="StrongWildcard"

                                     listenBacklog="10"

                                     maxBufferPoolSize="524288"

                                     maxBufferSize="65536"

                                     maxConnections="10"

                                     maxReceivedMessageSize="65536">

                              <readerQuotas maxDepth="32"

                                                  maxStringContentLength="8192"

                                                  maxArrayLength="16384"

                                                  maxBytesPerRead="4096"

                                                  maxNameTableCharCount="16384" />

                             

                              <security mode="None">

                              </security>

                        </binding>

                  </netTcpBinding>

            </bindings>

       <behaviors>

                  <serviceBehaviors>

                        <behavior name="CalculatorServiceBehavior">

                              <serviceMetadata httpGetEnabled="true" />

                              <serviceDebug includeExceptionDetailInFaults="False                                " />

                        </behavior>

                  </serviceBehaviors>

            </behaviors>

      </system.serviceModel>

 

</configuration>

  

On the BizTalk Server side we need to generate the types corresponding to the WCF service. We do that using the WCF Adapter Metadata Wizard. Notice that the generated metadata is not related with a particular endpoint.

Finally in order to interact with the WCF service select the WCF-NetTcp adapter from the adapter list in the Send Port and configure the properties as illustrated in the following figure.

 

  

  

Notice the SOAP action header needs to be configured in order to identify the operation to invoke on the service side.

No Comments