Saturday, August 07, 2010

Apache ODE: Dynamic Headers (SOAP Headers)

SOAP headers that are not declaed in WSDL bindings can be used in ODE. If messages are present in the SOAP header they will be used but there is no validation as in other case (Headers as Abstract Message Parts)
I have attached the 2 test processes that I developed. They don’t have any fault handling at present but in production we need to handle faults since there can be no/different headers. Search for the part of code that says :-
                                                <bpel:copy>
                                                               <bpel:from>$input.payload//tns:input</bpel:from>
                                                               <bpel:to variable="output" header="ConversationId"></bpel:to>
                                                </bpel:copy>



In this case it is copying the input variable and adding header to the SOAP output. Similarly in the other case it is parsing the required field from the header.


Add header:-


Input


  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://helloWorld">
  2:    <soapenv:Header/>
  3:    <soapenv:Body>
  4:       <hel:HelloWorldRequest>
  5:          <hel:input>Test</hel:input>
  6:       </hel:HelloWorldRequest>
  7:    </soapenv:Body>
  8: </soapenv:Envelope>
  9: 


Output


  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  2:    <soapenv:Header>
  3:       <input xmlns="http://helloWorld">Test</input>
  4:    </soapenv:Header>
  5:    <soapenv:Body>
  6:       <HelloWorldResponse xmlns="http://helloWorld">
  7:          <tns:result xmlns:tns="http://helloWorld"/>
  8:       </HelloWorldResponse>
  9:    </soapenv:Body>
 10: </soapenv:Envelope>
 11: 


Parse Header:-


Input


  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://helloWorld">
  2:    <soapenv:Header>
  3:                 <hel:ConversationId>This header will be parsed to get this message</hel:ConversationId>
  4:    </soapenv:Header>
  5:    <soapenv:Body>
  6:       <hel:HelloWorldRequest>
  7:          <hel:input>?</hel:input>
  8:       </hel:HelloWorldRequest>
  9:    </soapenv:Body>
 10: </soapenv:Envelope>
 11: 





Output


  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  2:    <soapenv:Body>
  3:       <HelloWorldResponse xmlns="http://helloWorld"> This header will be parsed to get this message </HelloWorldResponse>
  4:    </soapenv:Body>
  5: </soapenv:Envelope>
  6: 





Code

No comments:

Post a Comment

Thank you for your feedback