Tuesday, April 27, 2010

OSB transport headers

<con:transport xmlns:con="http://www.bea.com/wli/sb/context">
  <con:uri>/PVOSBProject1/PVTestFault01</con:uri>
  <con:mode>request-response</con:mode>
  <con:qualityOfService>best-effort</con:qualityOfService>
  <con:request xsi:type="http:HttpRequestMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
      <http:Content-Type>text/xml; charset=utf-8</http:Content-Type>
      <http:SOAPAction>"generateFault2"</http:SOAPAction>
    </tran:headers>
    <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
  </con:request>
  <con:response xsi:type="http:HttpResponseMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <tran:headers xsi:type="http:HttpResponseHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
      <http:Content-Type>text/xml</http:Content-Type>
    </tran:headers>
    <tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
  </con:response>
</con:transport>


You can  customize the tran:headers section with a tran:user-header with a custom header

      <tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
        <tran:user-header name="messageHistory" value="ciaobellagioia"/>
        <http:Content-Type>text/xml; charset=utf-8</http:Content-Type>

this is how I added the header:



This way the Caller Proxy Service sets the header on the $outbound variable. The Called Proxy Service MUST be set with the option "GET ALL HEADERS" in the "Transport" tab, otherwise the transport header will be lost. Or, at least, add the "messageHistory" in the list of headers to be explicitly copied.
The Called Proxy Service  will get the header in the $inbound variable, transport section.

OF COURSE you whould not put messageHistory in a transport header, the right place is in the SOAP header. Don't confuse TRANSPORT HEADER with SOAP HEADER.

No comments: