0

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.

enter image description here

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>
Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48
user1205746
  • 2,464
  • 7
  • 34
  • 62

1 Answers1

0

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/>.

NameRakes
  • 427
  • 4
  • 12
  • Thank you for pointing out the maxOccurs. No wonder it gave out weird warnings. As for , my goal is to hopefully catch anything and not just . I hope I can throw anything in there in the future and not just error message. Hopefully, this is not against good practice. – user1205746 Jan 17 '17 at 18:16