How to register WCF extensions in BizTalk?

The post was orignally published here.

In more advanced WCF scenarios, the BizTalk standard functionality can be insufficient.  In those cases, WCF extensibility can help us to overcome the limitations of the standard BizTalk WCF adapters.  Typical examples are custom MessageInspectors, ErrorHandlers, Decoders and AuthorizationBehaviors.

Once you have registered the extensibility, you can configure it on the WCF-Custom or WCF-CustomIsolated receive and send ports:

image

When the WCF send or receive port is executed, your WCF extensibility objects will be injected into the WCF channel stack.

How to register WCF extensions?

BizTalk 2006 R2 and BizTalk 2009

In the previous versions of BizTalk, there was only one way to register WCF extensions: the machine.config.

The C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config is needed for 32-bit processes:

  • BizTalk 32-bit host instances
  • IIS 32-bit applications
  • BizTalk Administration Console

The C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config is needed for 64-bit processes

  • BizTalk 64-bit host instances
  • IIS 64-bit applications

image

BizTalk 2010: the new feature

BizTalk Server 2010 comes with a nice new feature for registering your WCF extensibility assemblies. The new feature allows you to avoid the machine.config and to register them in BizTalk itself. Let’s have a look!

  • Browse to the WCF-Custom adapter handlers.

image

  • Open the receive or send handler.  Choose Properties.

image

  • Here you can import a web.config / app.config that contains your WCF extensions.

image

The caveat

Unfortunately, this doesn’t work if your receive port is hosted in IIS.  You can register the WCF extensions on the WCF-CustomIsolated adapter handlers. However, when the WCF-CustomIsolated receive port is called, you get an activation error:

“WebHost failed to process a request.

Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/45653674

Exception: System.ServiceModel.ServiceActivationException: The service ‘/ApplicationName/Service.svc’ cannot be activated due to an exception during compilation. The exception message is: Unable to create endpoint behavior configuration element from XML configuration.

Check the following:

1. Verify behavior element extensions in machine.config are correctly configured.
2. Restart the application if machine.config was recently updated.
3. Ensure the configuration is valid XML that conforms to the configuration schema.”

Adding the WCF extensions in the corresponding web.config of IIS also doesn’t solve this issue.  The only solution I’ve found is to register them again in the machine.config.  Remember that BizTalk 2010 is .NET 4.0.

The C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config is needed for 32-bit processes:

  • BizTalk 32-bit host instances
  • IIS 32-bit applications
  • BizTalk Administration Console

The C:\Windows\Microsoft.NET\Framework64\v4.0.30319\CONFIG\machine.config is needed for 64-bit processes

  • BizTalk 64-bit host instances
  • IIS 64-bit applications

Conslusion

  • Only when using the WCF-Custom adapter in BizTalk 2010, you can register WCF extensions in BizTalk itself.
  • In all other scenarios, you need to register them in the corresponding machine.config.  This has the drawback that this also influences other applications on the server.

Please get in touch if you managed to get this working!

About me

Hi! I’m Toon Vanhoutte, a hands-on Azure architect – based in Belgium – with a big passion for teaching and helping people out. I’m happy to assist you during your Azure journey with high-quality advisory and I would love to teach you Azure’s possibilities via my tailored training courses.

Subscribe to the blog