2017-06-29 54 views
0

我无法让我的BizTalk地图在信封解析后处理消息。该映射似乎需要一个名称空间前缀,但已解析的消息没有前缀。如果我向根添加一个前缀,就像这个<ns0:Encounter xmlns:ns0="http://hl7.org/fhir/Encounters">那么当我在visual studio中使用测试图时,地图就可以正常工作。如果没有前缀,我仍会从映射中获取输出,但只有常量映射到目标架构中,没有任何映射来自源架构。当名称空间前缀丢失时,BizTalk映射不起作用

我收到以下错误消息为每映射元素

"error btm1044: Input validation error: The 'value' attribute is not declared."

我试图从不合格到合格的改变将elementFormDefault值在一个单独的职位的建议,但仍然没有运气。

经过信封辩论后,我得到了以下XML。请注意,没有名称空间前缀。 如果我停止发送端口并查看消息类型为http://hl7.org/fhir/Encounters#Encounter的消息。

<?xml version="1.0" encoding="utf-8"?> 
<Encounter xmlns="http://hl7.org/fhir/Encounters"> 
    <id value="ac34e2c2-6080-4c46-9ec5-d7340a7c4177" /> 
    <extension url="https://api-foo.org/documents/fhir/extensions/encounter-facility"> 
     <valueString value="foo" /> 
    </extension> 
    <extension url="https://api-foo.org/documents/fhir/extensions/encounter-service"> 
     <valueString value="fooo" />....... 

我的模式是这样的

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

有没有办法让图/架构与信息工作的是,还是有办法让debatched消息的前缀。

我也有一个自定义的管道组件,在debatching之前更改传入消息的命名空间。我不确定这是否会导致代码如下所示的问题。

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> 
+0

在哪一部分接收管道的是你的命名管道组件?你使用什么方法来评论这个消息?使用信封模式? (如果是这样,请为此显示模式)如果将地图从端口中取出,消息的上下文中有哪些消息类型? Pipeline中是否也有一个XML验证器? (因为这个错误看起来是来自那个而不是地图,或者是你在测试地图时从Visual Studio中得到的错误?) – Dijkgraaf

+0

您是否使用BizTalk HL7反汇编程序? –

+0

在管道组件中,我使用HL7 FHIR库将传入的json转换为XML,然后更改Execute方法中的名称空间。管道组件位于管道的Decode部分。标准的XML反汇编程序组件位于管道的反汇编部分。没有其他组件被使用。我将用信封模式和其他请求的信息更新主文章。 – David

回答

1

由于您使用FHIR的JSON表示,第一个问题应该是,你甚至需要使用XML命名空间。

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

您可以参考这个wiki文章了解详情:BizTalk: Simplify BizTalk Dev by Using the Empty Namespace

+0

感谢@ Johns-305我将看看这个和你对我的其他线程的回应,并做出正确地做到这一点所需的设计更改。 – David

+0

对于其他人阅读,在这个线程上有更多关于这个问题 [链接](https://stackoverflow.com/questions/44837027/add-namespace-and-alias-to-existing-xml)。其中@ Johns-305提供解决方案的其他链接。 – David

+0

我切换到在我的信封和msg模式上使用空名称空间,并在XmlDisassembler中指定模式,如上面链接中所述,我的应用程序现在按预期工作。再次感谢您的帮助。 @ Johns-305 - 文章提到“Visual Studio解决方案为社区命名空间移除”即将推出“。这个VS解决方案是否可供下载? – David

相关问题