0

我正在尝试对 BizTalk 2010 中的信封做一些实验,因为一条消息将由多个项目组成。我的信封架构如下:

信封:

<?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>

单个项目的架构如下。每个信封可以包含多个项目。

<?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>

当我尝试创建我的 xml 数据时,BizTalk 不喜欢我的 xml,并且在我的第二个项目上有一条波浪线,表示无效的子元素。

在此处输入图像描述

有人能指出我的数据有什么问题吗?

<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>
4

1 回答 1

0

默认情况下,序列中的项目数为 1。您应该指定maxOccurs为无界或您期望Envelope元素上的确切项目数(为清楚起见,我删除了注释):

<xs:element name="Envelope">
  <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
      <xs:any />
    </xs:sequence>
  </xs:complexType>
</xs:element>

另一个建议:如果您只期望内部 Error的元素Envelope,更好的做法是指定<xs:Error/>而不是<xs:any/>.

于 2017-01-16T23:34:00.813 回答