I am trying to do some experiment on envelope in BizTalk 2010 when one message will compose of multiple items. I have the schema for the envelope as follow:
Envelope:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://TestFromMSDN" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestFromMSDN" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo is_envelope="yes" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Envelope">
<xs:annotation>
<xs:appinfo>
<b:recordInfo body_xpath="/*[local-name()='Envelope' and namespace-uri()='http://TestFromMSDN']" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The schema for individual item is as follow. Each envelope could contain multiple items.
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://TestFromMSDN" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://TestFromMSDN" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Error">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Type" type="xs:int" />
<xs:element name="Priority" type="xs:string" />
<xs:element name="Description" type="xs:string" />
<xs:element name="ErrorDateTime" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I tried to create my xml data, BizTalk does not like my xml and had a squiggly line on my second item, saying invalid child element.
Can someone point out what is wrong in my data?
<ns0:Envelope xmlns:ns0="http://TestFromMSDN">
<ns0:Error>
<ns0:ID>102</ns0:ID>
<ns0:Type>0</ns0:Type>
<ns0:Priority>High</ns0:Priority>
<ns0:Description>Sproket query fails</ns0:Description>
<ns0:ErrorDateTime>1999-05-31T13:20:00.000-05:00</ns0:ErrorDateTime>
</ns0:Error>
<ns0:Error>
<ID>16502</ID>
<Type>2</Type>
<Priority>Low</Priority>
<Description>Time threshold exceeded</Description>
<ErrorDateTime>1999-05-31T13:20:00.000-05:00</ErrorDateTime>
</ns0:Error>
</ns0:Envelope>
By default the number of items in the sequence is 1. You should specify maxOccurs
to be unbounded or the exact number of items you expect on your Envelope
element (I have removed annotation for clarity):
<xs:element name="Envelope">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:any />
</xs:sequence>
</xs:complexType>
</xs:element>
Another suggestion: if you are expecting only Error
elements inside Envelope
, a better practice is to specify <xs:Error/>
instead of <xs:any/>
.