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?

2 comments:

Unknown said...

Hi Martin

I have run into this same problem and would really like to know about the details of the Services Application you built.

I am trying to do the same and have a CommonServices BizTalk applcation which my other applcations reference. My CommonServies application adds a generated items to consume a WCF service.

Now I am slightly puzzled as to how to get my normal BizTalk applications to actually use the reference to the COmmonServices project to use the WCF referenced service.

Any help would be great.

many thanks
Josh

Martin Bring said...

Hi Joshan.

I think the best way would be to create new internal messasage types, that the "common application"'s wcf orchestration subcribes to and will be the ouput from the "normal" applications. That way you hide the generated schemas and will be able to change service without anyone needs to know.

The other way is to make all message types and ports in the generated orchestration public. That way you can used them from the projects that needs them. Of course you will have to remember that if the service is updated and you have to regenerate the orchestration :)

Hope this will help.