【问题标题】:How to handle this XML in BizTalk如何在 BizTalk 中处理此 XML
【发布时间】:2012-06-22 09:41:03
【问题描述】:

我被传递了一大块用于在 BizTalk 中处理的 XML。 xml主要是这样的形式:

<FieldItem>
    <Name>EmploymentStatus</Name>
    <Value xsi:type="xsd:string">1</Value>
</FieldItem>

但是,有时名称值对会变得更复杂,看起来像这样:

 <FieldItem>
        <Name>EducationAndQualifications</Name>
        <Value xsi:type="RepeatingFieldArray">
            <Fields>
                <RepeatingField>
                    <Items>
                        <FieldItem>
                            <Name>Qualification</Name>
                            <Value xsi:type="xsd:string">umbraco</Value>
                        </FieldItem>
                        <FieldItem>
                            <Name>Establishment</Name>
                            <Value xsi:type="xsd:string">IBM</Value>
                        </FieldItem>
                        <FieldItem>
                            <Name>DateAchieved</Name>
                            <Value xsi:type="xsd:string">June 2011</Value>
                        </FieldItem>
                    </Items>
                </RepeatingField>
            </Fields>
        </Value>
    </FieldItem>

我已尝试通过 BizTalks 生成项目向导生成架构,但它无法应对类型更改以及可能存在或不存在的其他重复字段。

因此,我正在寻求有关此方面最佳前进方式的建议/指导。是否可以创建 BizTalk 愿意处理的架构?或者,我目前偏爱的解决方案,是否应该创建一个自定义管道组件,将其拆分为单独的消息?

感谢您的宝贵时间。

更新

如果我创建以下架构:

<?xml version="1.0" encoding="utf-16" ?> 
<xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="FormData">
    <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="FormName" type="xsd:string" /> 
          <xsd:element name="FormInstanceId" type="xsd:string" /> 
          <xsd:element name="Status" type="xsd:string" /> 
          <xsd:element name="Data">
              <xsd:complexType>
                  <xsd:sequence>
                      <xsd:element maxOccurs="unbounded" name="FieldItem">
                          <xsd:complexType>
                              <xsd:sequence>
                                  <xsd:element name="Name" type="xsd:string" /> 
                                  <xsd:element minOccurs="0" maxOccurs="unbounded" name="Value" nillable="true" type="xsd:anyType" /> 
                              </xsd:sequence>
                          </xsd:complexType>
                      </xsd:element>
                  </xsd:sequence>
              </xsd:complexType>
          </xsd:element>
      </xsd:sequence>
  </xsd:complexType>

我收到以下错误:

这是一个无效的 xsi:type 'RepeatingFieldArray'

所以我仍然倾向于编写一些代码来解决这一切......

【问题讨论】:

    标签: xml xsd schema biztalk biztalk-2010


    【解决方案1】:

    我决定采用自定义管道组件路线,将重复数据提取到一个通用模式中,该模式也匹配通用的重复键/值对。我添加了其他字段,以便可以通过其部分识别每条消息。见下文:

    <?xml version="1.0" encoding="utf-16" ?> 
        <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:annotation>
        <xs:appinfo>
        <b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
          <b:namespace prefix="ns0" uri="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" location=".\PropertySchema.xsd" /> 
          </b:imports>
          </xs:appinfo>
          </xs:annotation>
        <xs:element name="Root">
        <xs:annotation>
        <xs:appinfo>
        <b:properties>
          <b:property name="ns0:Interface" xpath="/*[local-name()='Root' and namespace-uri()='']/*[local-name()='Interface' and namespace-uri()='']" /> 
          </b:properties>
          </xs:appinfo>
          </xs:annotation>
        <xs:complexType>
        <xs:sequence>
          <xs:element name="Interface" type="xs:string" /> 
          <xs:element name="Type" type="xs:string" /> 
          <xs:element name="FormName" type="xs:string" /> 
          <xs:element name="FormInstanceId" type="xs:string" /> 
          <xs:element name="Status" type="xs:string" /> 
        <xs:element name="Data">
        <xs:complexType>
        <xs:sequence>
        <xs:element maxOccurs="unbounded" name="FieldItem">
        <xs:complexType>
        <xs:sequence>
          <xs:element name="Name" type="xs:string" /> 
          <xs:element name="Value" type="xs:string" /> 
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:schema>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-07
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 2011-01-11
      • 1970-01-01
      相关资源
      最近更新 更多