缺少命名空间前缀时BizTalk映射不起作用

缺少命名空间前缀时BizTalk映射不起作用,biztalk,biztalk-2013,Biztalk,Biztalk 2013,信封取消匹配后,我无法让BizTalk映射处理邮件。映射似乎需要名称空间前缀,但已删除的消息没有前缀。如果我向根添加前缀,如下图所示,那么当我在VisualStudio中使用测试映射时,映射可以正常工作。如果没有前缀,我仍然从映射中获得输出,但是只有常量映射到目标模式,没有任何内容从源模式映射 对于每个映射元素,我都会收到以下错误消息 “错误btm1044:输入验证错误:“值”属性未声明。” 我曾尝试过将elementFormDefault的值从不合格更改为合格,正如在另一篇文章中建议的那样,但

信封取消匹配后,我无法让BizTalk映射处理邮件。映射似乎需要名称空间前缀,但已删除的消息没有前缀。如果我向根添加前缀,如下图所示,那么当我在VisualStudio中使用测试映射时,映射可以正常工作。如果没有前缀,我仍然从映射中获得输出,但是只有常量映射到目标模式,没有任何内容从源模式映射

对于每个映射元素,我都会收到以下错误消息

“错误btm1044:输入验证错误:“值”属性未声明。”

我曾尝试过将elementFormDefault的值从不合格更改为合格,正如在另一篇文章中建议的那样,但仍然没有成功

在信封去除之后,我最终得到了以下XML。请注意,没有名称空间前缀。 如果我停止发送端口并查看已删除的消息,则消息类型为

这是信封模式

    <?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://hl7.org/fhir/Encounters" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://hl7.org/fhir/Encounters" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo is_envelope="yes" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Bundle">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo body_xpath="/*[local-name()='Bundle' and namespace-uri()='http://hl7.org/fhir/Encounters']/*[local-name()='entry' and namespace-uri()='http://hl7.org/fhir/Encounters']/*[local-name()='resource' and namespace-uri()='http://hl7.org/fhir/Encounters']" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="total">
          <xs:complexType>
            <xs:attribute name="value" type="xs:unsignedByte" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element maxOccurs="unbounded" name="entry">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="resource">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Encounter">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:any />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

既然您使用的是FHIR的JSON表示,那么第一个问题应该是您是否需要使用Xml名称空间

在BizTalk中处理本机JSON内容时,我建议在所有Xml处理中使用空名称空间


有关更多详细信息,请参阅这篇Wiki文章:

您的命名空间管道组件位于接收管道的哪一部分?您使用什么方法来解除对消息的锁定?使用信封模式?(如果是,则显示该模式)如果将映射从端口上移除,则消息上下文中的消息类型是什么?您是否也有一个XML验证程序在管道中?(因为该错误看起来是来自该映射,而不是映射,或者是测试映射时从Visual Studio得到的错误?)您是否使用BizTalk HL7反汇编程序?在管道组件中,我使用HL7 FHIR库将传入的json转换为XML,然后在Execute方法中更改名称空间。管道组件位于管道的解码部分。标准XML反汇编程序组件位于管道的反汇编部分。不使用其他组件。我将用信封模式和其他要求的信息更新帖子的主要内容。对帖子进行了几次更新,以包括@DijkgraafThanks@Johns-305要求的信息。我将看看这篇文章和您对我的其他帖子的回复,并做出正确操作所需的设计更改。对于其他阅读此文章的人,请参阅此线程上存在相同的问题。其中@Johns-305提供了指向解决方案的附加链接。我切换到在信封和msg模式上使用空名称空间,并按照上面链接中所述在Xml反汇编程序中指定模式,我的应用程序现在正按预期运行。再次感谢你的帮助@Johns-305-文章提到“社区名称空间移除的Visual Studio解决方案”即将推出。此VS解决方案可供下载吗?@David抱歉,这是一个错误,已更正。示例项目中只有编译的程序集可用。
  <?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://hl7.org/fhir/Encounters" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://hl7.org/fhir/Encounters" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Encounter">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id">
          <xs:complexType>
            <xs:attribute name="value" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element maxOccurs="unbounded" name="extension">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="valueInteger">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:unsignedByte" use="required" />
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" name="valueString">
                <xs:complexType>
                  <xs:attribute name="value" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="url" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element> ............
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
    {
        if (Enabled)
        {
            try
            {
                IBaseMessagePart bodyPart = inmsg.BodyPart;

                if (bodyPart != null)
                {
                    string json;

                    using (Stream originalDataStream = bodyPart.GetOriginalDataStream())
                    {
                        if (originalDataStream != null)
                        {
                            //Read the json message
                            using (TextReader tr = new StreamReader(originalDataStream))
                            {
                                json = tr.ReadToEnd();
                            }

                            //Use FHIR-NET-API to create a FHIR resource from the json
                            Hl7.Fhir.Serialization.ResourceReader resourceReader = new Hl7.Fhir.Serialization.ResourceReader(FhirJsonParser.CreateFhirReader(json), ParserSettings.Default);

                            //switch the namespace
                            var doc = XElement.Parse(Hl7.Fhir.Serialization.FhirSerializer.SerializeToXml(resourceReader.Deserialize()));

                            XNamespace toNs = Namespace;
                            doc.DescendantsAndSelf().Attributes().Where(a => a.IsNamespaceDeclaration).Remove();
                            var ele = doc.DescendantsAndSelf();
                            foreach (var el in ele)
                                el.Name = toNs + el.Name.LocalName;

                            //Create the new BizTalk message
                            var memoryStream = new MemoryStream();
                            doc.Save(memoryStream);
                            //  memoryStream.Write(resourceXmlBytes, 0, resourceXmlBytes.Length);
                            memoryStream.Position = 0;
                            inmsg.BodyPart.Data = memoryStream;
                        }
                    }
                }

                return inmsg;
            }
            catch (Exception e)
            {
                GenericEventLogger.LogEvent(
                ExceptionSource,
                String.Format("An exception [{0}] occured in [{1}( )]. \n\nMessage: \n{2} \n\nStack Trace: \n{3}",
                                e.GetType().Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName,
                                e.Message,
                                e.StackTrace),
                EventLogEntryType.Error,
                999);
                throw;
            }
        }

        return inmsg;
    }
    <?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://hl7.org/fhir/Encounters" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://hl7.org/fhir/Encounters" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo is_envelope="yes" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Bundle">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo body_xpath="/*[local-name()='Bundle' and namespace-uri()='http://hl7.org/fhir/Encounters']/*[local-name()='entry' and namespace-uri()='http://hl7.org/fhir/Encounters']/*[local-name()='resource' and namespace-uri()='http://hl7.org/fhir/Encounters']" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="total">
          <xs:complexType>
            <xs:attribute name="value" type="xs:unsignedByte" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element maxOccurs="unbounded" name="entry">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="resource">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Encounter">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:any />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>