Lately, I had the task to create a generic WCF netTcp endpoint within BizTalk. The purpose was to create a single BizTalk ESB endpoint for each front-end application. BizTalk has the task to route and transform the SOAP requests to the corresponding back-end services.
I already had experience with hosting such an endpoint in-process (with the Custom adapter), but now it was required to host the endpoint in IIS (with the Custom-Isolated adapter). The reason for this decision is the fact that IIS, in combination with Windows Server AppFabric, adds extra tooling and manageability.
Enable Windows Activation Services
- Add WAS as a Windows feature:
- Turn on WCF Non-HTTP Activation
- Start all WAS Windows Services. Change their startup type to Automatic. You can do this via Properties.
Create IIS endpoint
- Create a web service directory: C:\inetpub\wwwroot\BlogService
- Open IIS Manager and convert the folder to an application
- Choose an application pool which is configured with the BizTalk isolated host user for .NET Framework 4.0
- Enable netTcp for the Default Web Site, via the Advanced Settings:
- Enable netTcp for the BlogService application, via the Advanced Settings:
- Add GenericEsbEndpoint.svc to the web service directory
- GenericEsbEndpoint.svc tells IIS to use the ServiceHostFactory of the BizTalk WCF adapter:
<%@ ServiceHost Language="c#" Factory="Microsoft.BizTalk.Adapter.Wcf.Runtime.CustomWebServiceHostFactory, Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
- A web.config can be added, but all service behaviors (e.g. serviceDebug) can be configured on your BizTalk receive location too.
Create BizTalk receive location
- Create a two-way receive port
- Create a two-way receive location and configure with the Custom-Isolated Adapter
- Configure the adapter URI with the format /<IIS Application Name>/<Service.svc>. Don’t use the scheme “net.tcp://” here!
- Configure the netTcp binding. Disable transport security (for performance reasons).
- Enable the BizTalk receive location
- Now you can additionally set up send ports and filters, to route the submitted SOAP request to the correct back-end services. Routing can be based on multiple properties, but the SOAP Action (WCF.Action) seems most suitable. Also transformations must be added in some cases.
Update the client binding
- The client needs to be updated to send to the generic BizTalk endpoint, instead of directly to the back-end service. Update the client with the following address format: net.tcp://<machinename>:<tcpPortNumber>//<IIS Application Name>/<Service.svc>
contract="PersonSvc.ICoditService" name="NetTcpBinding_ICoditService" />
- The tcpPortNumber can be configured in the Site Bindings of the Default Web Site