Ramblings of An OverTaxed Mind

I Think I Think.... So Am I?

  Home  |   Contact  |   Syndication    |   Login
  14 Posts | 0 Stories | 16 Comments | 0 Trackbacks

News

Archives

Post Categories

Tuesday, April 08, 2008 #

I ran into an interesting issue a couple of weeks ago and I thought I would share.

1st, the meat of the post.

If you have extracted the schemas from an XmlSerializable object and deployed those schemas to BizTalk, you can't use that object (or any of its dependant objects) as a BizTalk message type.
Why? Because BizTalk registers XmlSerializable types that are used as messages as schemas. If you have already registered the schema, you will end up with message type duplication.

_____________________________________________________________________________________________________________________________________________________________________
I was working on an application where BizTalk was operating as a SOA messaging bus.
The system was designed to receive data from a number of different systems, map that data to a canonical object model.

The canonical object model consisted of several XmlSerializable classes written in C#.
I used xsd.exe to extract schemas for the objects so that I could use the BizTalk mapper to map to and from the object model.

All of this worked great until I decided to break some common functionality into a separate orchestration.
Since no mapping would occur in the Helper orchestration, I decided to pass the canonical object directly to the orchestration.
I also decided that calling the Helper orchestration via Direct Message Box binding would increase its overall utility and reduce coupling.
The end result was that I created a Message Type and a Port Type that referenced the canonical object instead of the canonical object schemas.

I deployed my changes and submitted a test message.
As soon as my "core" orchestration called the new helper orchestration, I got a familiar error message in an unexpected point in the process.

Cannot locate document specification because multiple schemas matched the message type
 

My first reaction was total disbelief. I hadn't changed any schemas. In fact, I didn't even redeploy my schema project.
I checked the Schemas folder under BizTalk Application 1 and there was only one schema with the offending namespace#rootnode combination.
So I checked the Schemas folder under <All Artifacts> and there where two schemas... and the new schema was filed under the BizTalk.System Application.

I this point, I was quite confused. You can't deploy to BizTalk.System. It is for system use only. 
I dug a little deeper and discovered that my Canonical object C# assembly was the source of the duplicate schema... and then I understood.

My canonical object model was already "registered" in BizTalk via the schema I generated to enable mapping to the object model.
When I used the canonical class as a message type, BizTalk extracted the schema from the serialization metadata and registered the resulting message type with the messaging engine.
Because both schemas are the same, I had duplicate message types.

Luckily the fix was simple. I changed the Message Type and a Port Type to use the canonical object schemas and serialized between the different object representation in the orchestrations before sending the data to the Message Box.