Thursday, March 12, 2009

Schema collision using same WCF service from multiple BizTalk projects

I just had a problem I haven't had for some time, "Cannot locate document specification as multiple schemas match the message type".

This happens when schemas with the same Root Node name and Namespace are deployed to BizTalk. To find the correct schema these two parameters are to only thing you got in XML world, so the pair need to be unique.

The new thing was that we are starting to use a lot of WCF services in the current projects, so whats was the relation? The problem occurs since many projects referenced the same service. That way the database would have the same schema deployed several times and a collision is a fact.

I thought this problem should have occured to me before, with multiple projects referencing same web service, but then I found some info about changes in subscription mechanism between SOAP and WCF. Seroter writes: Differences in BizTalk Subscription Handling for SOAP and WCF Adapter Messages and I also thought about how the SOAP adapter was used.

With the SOAP adapter the common settings have been "Passthrough" on both Send and Receive Pipeline. The subscription has been handled by operation name and other mechanisms and there has been no need to promote Message Type and therefore no need for "Xml receive" pipeline, and its schema resolving disassembler.

In WCF the subscription mechanism have change and the common settings are "Passthrough" on the Send pipeline and "Xml Receive" on the Receive pipeline. Then the "Xml disassmbler" will run and Message Type will be promoted.

If you have more than one project consuming the same WCF service deployed you will end up with "Error....multiple schemas...deployed".

Either you can create your own pipeline to limit the disassembler to look for schemas in a specific assembly or, as we have done, create a "Service project" and deploy that to a common Application (with BTS 2006).

So my project structure now looks like

x.y.Schemas.Internal
x.y.Schemas.External
some.companyglobal.namespace.Services
x.y.Map
x.y.Process
x.y.Pipeline

(I started structure my projects different after reading Dan's blog: BizTalk Visual Studio Solution Structure, with the small change of name for the Orchestration project to "Process". )

How do you solve using same WCF service from multiple projects?