Wednesday, August 11, 2010

Apache ODE : Headers as Abstract Message Parts

The Apache ODE web site does not do a good job at explaining the “Headers as Abstrct Message Parts” method of handling the headers. I have explained here how you can define soap headers in the wsdl so the BPEL process expects them in the header and how you can parse these headers to get information.

Basically if you follow the normal development pattern what you will end up with is http://www.mail-archive.com/axis-user@ws.apache.org/msg42282.html and you will end up with the error message :

More than one part for message HelloWorldRequestMessage


Referring to the base engine which is Axis 2 : http://wso2.org/library/2935 I modified my code to make the wsdl:input say:-



            <input>
<soap:body parts="payload" use="literal" />
<soap:header message="tns:HelloWorldRequestMessage" part="helloElement" use="literal"/>
</input>



The wsdl:operation was defined as:-



        <operation name="process">
<input message="tns:HelloWorldRequestMessage" />
<output message="tns:HelloWorldResponseMessage"/>
</operation>



And the wsdl:message was defined as:-



    <message name="HelloWorldRequestMessage">
<part name="payload" element="tns:HelloWorldRequest"/>
<part name="helloElement" element="tns:HelloElement"/>
</message>



The element was defined in the normal fashion:-



            <element name="HelloElement">
<complexType>
<sequence>
<element name="username" type="string"/>
<element name="role" type="string"/>
</sequence>
</complexType>
</element>



 



In the BPEL you retrieve the header from the input message which is mapped to HelloWorldRequestMessage



            <bpel:copy>
<bpel:from variable="input" part="helloElement" />
<bpel:to variable="output" part="payload"/>
</bpel:copy>



Input



  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://helloWorld"> 
  2:    <soapenv:Header> 
  3:     <hel:HelloElement> 
  4:         <hel:username>Admin</hel:username> 
  5:         <hel:role>SuperUserAccess</hel:role> 
  6:     </hel:HelloElement> 
  7:    </soapenv:Header> 
  8:    <soapenv:Body> 
  9:       <hel:HelloWorldRequest> 
 10:          <hel:input>?</hel:input> 
 11:       </hel:HelloWorldRequest> 
 12:    </soapenv:Body> 
 13: </soapenv:Envelope>


Output



  1: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  2:     <soapenv:Body>
  3:          <HelloWorldResponse xmlns="http://helloWorld">
  4:                <username>Admin</username>
  5:                <role>SuperUserAccess</role>
  6:          </HelloWorldResponse>
  7:     </soapenv:Body>
  8: </soapenv:Envelope>
  9: 




Code

No comments:

Post a Comment

Thank you for your feedback