Monish Nagisetty's Space

Building connectivity on-premise, in the cloud and beyond

Document type “urn:schemas-contoso-com:ABCIntegration:Invoice/v1.0#Invoice” does not match any of the given schemas.

This is an issue that has been torturing me for a while and I have finally found the solution.  Big thanks to Richard Seroter who ran into this issue before and wrote a post about it.  Can you believe that it involves modifying code that is outside of BizTalk? For the record here is the error:

Error

There was a failure executing the receive pipeline: “Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “XML disassembler” Receive Port: “RP.CONTOSO.INVOICER.XML.INVOICE” URI: “/InvoiceService/InvoiceService.asmx” Reason: Document type “urn:schemas-contoso-com:ABCIntegration:Invoice/v1.0#Invoice” does not match any of the given schemas.

I feel bad for asking my dear colleague Arnulfo to look into this issue.  I had a hard time finding the solution. 

Artifacts

Schemas

  • Invoice (urn:schemas-contoso-com:ABCIntegration:Invoice/v1.0)
  • InvoiceEnvelope (urn:schemas-contoso-com:ABCIntegration:InvoiceEnvelope/v1.0) (Defined as an envelope schema)

Pipelines

  • XMLReceivePipeline (There is a Xml Disassembler component within this pipeline that has the DocumentSpecNames and EnvelopeSpecNames properties set to the fully qualified names of the Invoice Schema and InvoiceEnvelope schema respectively.

Receive Ports

  • RP.POEnvelope

Receive Locations

  • RL.POEnvelope.FILE
  • RL.POEnvelope.SOAP

Send Ports

  • SP.PO.FILE (with filter expression BTS.MessageType == “urn:schemas-contoso-com:ABCIntegration:Invoice/v1.0”)

FILE Scenario

  1. An InvoiceEnvelope XML file which contains multiple Invoices is dropped into a file directory.
  2. The envelope message is picked up by the FILE adapter and sent in through the XMLReceive pipeline. 
  3. The XML Disassembler component  within the pipeline de-batches the envelope message into individual Invoice messages and then submits them into the messagebox.
  4. The SP.PO.FILE send port subscribes to these Invoice messages and therefore consumes them out of the message box and sends them to the directory specified in the send port configuration.

Simple.  Right? So I thought instead of submitting this envelope via the FILE adapter, why not submit it via the SOAP adapter? I started with the BizTalk web service publishing wizard to publish the InvoiceEnvelope schema as a web service.  However, I realized that my InvoiceEnvelope has an any tag in the body of the envelope .  This would not be very helpful for my web service clients as it does not expose the Invoice schema in the WSDL nor allow them to populate the Invoice object programatically.

So I made the following modifications to my InvoiceEnvelope schema.

  • Imported the Invoice schema
  • Removed the <Any> element
  • Added a child record to the root element
  • Modified the child record’s datatype of the imported Invoice schema
  • Set the minOccurs/maxOccurs to 0/unbounded

After making these changes, I was curious to see if this had broken my FILE scenario described above.  I tested it and to my surprise it worked fine.

Now that the schema is to my liking, I generated a web service from the InvoiceEnvelope schema using the BizTalk Web Service Publishing Wizard.  I also went ahead and wrote a console app to call the web service. 

SOAP Scenario (Expected) 

  1. The console app calls the web service and submits an InvoiceEnvelope message that is wrapped in a SOAP message.
  2. The envelope message is picked up by the SOAP adapter and sent in through the XMLReceive pipeline. 
  3. The XML Disassembler component within the pipeline de-batches the envelope message into individual Invoice messages and then submits them into the messagebox.
  4. The SP.PO.FILE send port subscribes to these Invoice messages and therefore consumes them out of the message box and sends them to the directory specified in the send port configuration.
     

SOAP Scenario (Actual) 

  1. The console app calls the web service and submits an InvoiceEnvelope message that is wrapped in a SOAP message.
  2. The envelope message is picked up by the SOAP adapter and sent in through the XMLReceive pipeline. 
  3. The envelope message is NOT de-batched into individual Invoice messages.  Instead, I get the following error:  Document type “urn:schemas-contoso-com:ABCIntegration:Invoice/v1.0#Invoice” does not match any of the given schemas.

I was left scratching my head to figure out why the SOAP adapter should behave differently.  After all, it is going through the same receive pipeline.  I looked at the failed message in the BizTalk Group Hub and it was fine.  I even copied the failed message text and created a XML file to test it through the FILE adapter and it worked fine! Very confusing indeed!

The Solution

The solution involves modifying the web service code-behind file.  By default, the web service sets the bodyTypeAssemblyQualifiedName to the fully qualified name of the envelope schema.  Instead, this should be set to null.

string bodyTypeAssemblyQualifiedName = “Contoso.Schemas.POEnvelope, Contoso.Schemas, Version=1.0.0.” + “0, Culture=neutral, PublicKeyToken=1deae62f243c4cb1”; //Incorrect

string bodyTypeAssemblyQualifiedName = null; //Correct

Lessons Learned
Review the BizTalk Developer’s Troubleshooting Guide.  Apparently it contains solutions for many of the common (and uncommon/unusual/time-consuming) BizTalk dev issues. [:@]

I would like to revisit this issue to understand why the qualified name causes this problem.  Until then…

Cheers!

May 10, 2007 - Posted by | Uncategorized |

No comments yet.

Leave a comment