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>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

The wsdl:operation was defined as:-

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

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

And the wsdl:message was defined as:-

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

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

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>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

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>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s