2017-06-29 39 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