xsltsoapmappingbiztalksoapheader

BizTalk mapping: Getting a value from soapenv:Header


I'm trying to map a message from the following format via xslt:

<soapenv:Envelope xmlns:soapenv="..." ns...>
   <soapenv:Header>
      <ns:myHeader>
         <ns1:myData>VALUE_I_WANT</ns1:myData>
      </ns:myHeader>
   </soapenv:Header>
   <soapenv:Body>
      <ns2:otherData>
         ...
      </ns2:otherData>
   </soapenv:Body>
</soapenv:Envelope>

Currently my mapping handles all of the fields in the soapenv:Body tag, but for one of my mapped nodes I need the value in soapenv:Header > ns:myHeader > ns1:myData.

Is it possible to get a value from the soap header in XSLT and what kind of xpath would I need to achieve this?


Solution

  • Assuming you use the WCF-BasicHttp adapter, you could use xslt like you wanted, but only if you specified Envelope -- entire <soap:Envelope> as data selection for the SOAP Body element. If you don't specify it, your header will be removed from the message body and xpath statements on the header will be impossible.

    Your other option is getting the value from the context property InboundHeaders with namespace http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties. The adapter puts the SOAP header values into that InboundHeaders context property by default. If you need the context value in a mapping, without an orchestration, try looking into the community made Context Accessor Functoid.

    Doing your own property promotion on header values, like you asked for in the comments, is also possible, but not in xslt. Only if you add an XML Disassembler Pipeline Component, then make a schema of the entire soap message, then set promotions on the schema and finally; specify the schema in the Document schemas part of the Pipeline Component. I wouldn't suggest using this approach, as it requires you to deploy a soap schema which will be duplicate with the default BizTalk soap schema.