Charlie Mott

  Home  |   Contact  |   Syndication    |   Login
  20 Posts | 0 Stories | 18 Comments | 0 Trackbacks

News

View Charlie Mott's profile on LinkedIn



Archives

Post Categories

Article Source: http://geekswithblogs.net/charliemott

There are various blog articles that give sample .NET code that can be used to validate a message against a schema from a BizTalk orchestration.  These include: msdn, haloscan.com, biztalkgurus.com, eggheadcafe.com and Sujan Turlapaty.

Many of these blogs have subsequent comments about problems.  Under high loads, I too began to see these classes return “false positives” in my test environment.  (i.e. An XmlSchemaValidationException is being thrown against valid messages. When the messages are re-submitted individually, they pass validation without problems.)

Doing a bit more research into this, I found this Microsoft XML Team's WebLog article about the lack of thread safety of the XmlSchema and XmlSchemaSet classes. 

This article also states that "for some reason, this "breaks" more on 64-bit machines, but it's unsafe on all architectures".  This would explain why I only began to see the problem when we started testing on 64-bit servers.  I never experienced the problems on my 32-bit development or build machines.  Nor could I break the code in a unit test using Roy Osherove's ThreadTester.  So, another lesson learnt - always develop on the same OS type as the target machines.

To circumvent this problem, I am now calling a validation pipeline from the orchestrations. (I am using a pipeline with Saravana Kumar's Extended XML Validation Pipeline Component so that exceptions report all the validation errors, not just the first). This is working well. However, it does mean that I have had to set the orchestrations to run as long-running transactions.

Update (19/02/2010): Both the out-of-the-box validation pipeline component and Saravana Kumar's Extended XML Validation Pipeline Component, use the deprecated XmlSchemaCollection class. This class is more thread safe than the replacement XmlSchemaSet class.  As such, rather than the above solution of calling a pipeline from an orchestration, another solution would be to modify the validation method to use the XmlSchemaCollection instead of the XmlSchemaSet class.

posted on Tuesday, February 16, 2010 4:49 AM

Feedback

# re: XSD Validation from BizTalk Orchestrations 2/18/2010 6:18 AM Saravana Kumar
Hi Charlie, This is interesting to me. We use the extended validation pipeline component in a production environment, fairly high volume on a 64 bit OS. The system is in production for couple of years now and I personally haven't seen any major issues. Once I find sometime, I'll see whether I can replicate your issue.

Regards,
Saravana

# re: XSD Validation from BizTalk Orchestrations 2/18/2010 10:35 AM Charlie Mott
Hi Saravana, I too have had no problems with your pipeline component in a 64-bit environment. My guess is that this is because the code uses the XmlSchemaCollection class rather than the XmlSchemaSet. Maybe this is more thread safe. However, the XmlSchemaCollection class has been deprecated.
Another workaround to my problem (validating from orchestrations) might be to call an overloaded version of your "ValidatePart" method from an orchestration. However, I have not yet tried this.

# re: XSD Validation from BizTalk Orchestrations 2/19/2010 11:54 AM Charlie Mott
Using reflector, I had a look at the code of the out-of-the-box BizTalk 2009 XML Validator Pipeline component. The version has not been updated since 2006R2. The component continues to use the deprecated XmlSchemaCollection.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: