Windows Server - XmlSchemaValidationException in Biztalk 2006 project

Asked By vk on 02-Oct-07 04:14 AM
Hello everybody.

I need to validate XML messages passed in orchestrations in Biztalk 2006
project against XSD schema. Message schemas in Biztalk 2006 project compiled
into classes derived from Microsoft.XLANGs.BaseTypes.SchemaBase. So, if we
have object Type schemaType, which contain type of our Xml schema, we can
create instance of object SchemaBase, something like that:

Microsoft.XLANGs.BaseTypes.SchemaBase btsSchemaBase  =
( Microsoft.XLANGs.BaseTypes.SchemaBase )
Activator.CreateInstance( schemaType );

and then, using public property  XmlSchema btsSchemaBase.Schema, can
validate our message against it schema.

Everything simple. But there is a problem here. The fact is that XSD schemas
in my project have included schemas, and although
Microsoft.XLANGs.BaseTypes.SchemaBase has mechanism to work with included
schemas, sometimes types from included schemas became undefined. And I have
exception, something like that:

Uncaught exception (see the 'inner exception' below) has suspended an
instance of service
'MyProject.IS.Clipboard.Process_Publication(4fd60ef2-14f1-8341-41aa-1b6f5c75d344)'.
The service instance will remain suspended until administratively resumed or
terminated.
If resumed the instance will continue from its last persisted state and may
re-throw the same unexpected exception.
InstanceId: 23586292-9ba8-4f40-99cf-520313c5104a
Shape name:
ShapeId: 00000000-0000-0000-0000-000000000000
Exception thrown from: segment 1, progress 42
Inner exception: Type
'http://schemas.myProject.ru/is/clipboard/:t_foreign_system' is not declared.

Exception type: XmlSchemaValidationException
Source: System.Xml
Target Site: Void
SendValidationEvent(System.Xml.Schema.XmlSchemaValidationException,
System.Xml.Schema.XmlSeverityType)
The following is a stack trace that identifies the location where the
exception occured

at
System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity)
at
System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(XmlSchemaException e)
at System.Xml.Schema.XmlSchemaValidator.RecompileSchemaSet()
at System.Xml.Schema.XmlSchemaValidator.Init()
at System.Xml.Schema.XmlSchemaValidator..ctor(XmlNameTable nameTable,
XmlSchemaSet schemas, IXmlNamespaceResolver namespaceResolver,
XmlSchemaValidationFlags validationFlags)
at System.Xml.XsdValidatingReader.SetupValidator(XmlReaderSettings
readerSettings, XmlReader reader, XmlSchemaObject partialValidationType)
at System.Xml.XsdValidatingReader..ctor(XmlReader reader, XmlResolver
xmlResolver, XmlReaderSettings readerSettings, XmlSchemaObject
partialValidationType)
at System.Xml.XmlReader.AddValidation(XmlReader reader, XmlReaderSettings
settings)
at System.Xml.XmlReader.CreateReaderImpl(Stream input, XmlReaderSettings
settings, Uri baseUri, String baseUriStr, XmlParserContext inputContext,
Boolean closeInput)
at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings,
String baseUri)
at System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings)
at 'MyProject.IS.Clipboard.CSharp.Utils.ValidateMessage(XLANGMessage msg,
XmlSchema schema)
at 'MyProject.IS.Clipboard.Process_Publication.segment1(StopConditions
stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s,
StopConditions stopCond, Exception& exp)

In practice, I have 30 - 40 exceptions on 1000 succeed messages for same
schema.

How can I resolve this problem? Maybe there is other way to validate XML
messages by type in Biztalk 2006 project exists?

Thank you.




Jan Eliasen replied on 02-Oct-07 07:34 AM
On Tue, 2 Oct 2007 01:14:02 -0700, v.k.e


Well, pipelines are usually used to validate XML. Any particular
reason you aren't using pipelines for it?

If you create a custom receive pipeline, and add both the XML
Disassembler and the XML Validator components to it, and use this
pipeline in your receive location, all messages going through this
receive location is validated automatically against its schema.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Tomm replied on 02-Oct-07 10:46 AM
Try this
http://www.topxml.com/rbnews/XmlDocument/re-22687_Cool-XSD-Validation-Function-for-Orchestration.aspx

--
http://blog.csdn.net/mail_dcb2
Dmitry S replied on 02-Oct-07 01:12 PM
Hello, Tommy. Thank you for reply.
Method, described in my first post, the same as there:
http://www.topxml.com/rbnews/XmlDocument/re-22687_Cool-XSD-Validation-Function-for-Orchestration.aspx
Unfortunately, it works not every time.
Sorry, I did not see something useful to my problem by this reference:
http://blog.csdn.net/mail_dcb2.
Dmitry S replied on 02-Oct-07 01:12 PM
Hello, Tommy. Thank you for reply.
Method, described in my first post, the same as there:
http://www.topxml.com/rbnews/XmlDocument/re-22687_Cool-XSD-Validation-Function-for-Orchestration.aspx
Unfortunately, it works not every time.
Sorry, I did not see something useful to my problem by this reference:
http://blog.csdn.net/mail_dcb2.
Jan Eliasen replied on 03-Oct-07 03:45 PM
And what is wrong in doing it in a pipeline?

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Dmitry replied on 04-Oct-07 12:07 PM
Hello, Jan Eliasen.
I have done so because I need to send notifications from my Biztalk project
with results of validation to system, which have sent the message.
Dmitry replied on 04-Oct-07 12:07 PM
Hello, Jan Eliasen.
I have done so because I need to send notifications from my Biztalk project
with results of validation to system, which have sent the message.
Jan Eliasen replied on 04-Oct-07 04:08 PM
On Thu, 4 Oct 2007 09:07:04 -0700, Dmitry S.

In BizTalk 2006, you can validate the input in the receive pipeline,
and enable routing for failed messages on the receive port. This way,
you get to route and handle failed messages.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Charlie Mott replied to Jan Eliasen on 20-Feb-10 06:27 AM
Have a read of this post.  http://geekswithblogs.net/charliemott/archive/2010/02/16/xsd-validation-from-biztalk-orchestrations.aspx