Most of the web services use soap headers to pass various kinds of information and it is required to manipulate those headers within a BPEL process when we are creating a complex business logic. Sometimes we have to deal with soap headers which aren't declared in the WSDL abstract message. These kind of headers are called Dynamic headers and both Apache ODE and WSO2 BPS can handle these type of soap headers.
For more information about header handling in Apache ODE, follow this article.
This post will show you how to handle soap headers, covering following scenarios,
- Reading a soap header in request message.
- Create a new soap header in a variable and assign a value to it.
- Copying soap header from one variable to another.
To demonstrate above scenarios let's consider this simple BPEL process. These are process's default request and response messages.
1. Reading SOAP Header in Request Message.
Let's read "echo" header from the input message and set its value into the process output message (to result element). To do this, add another copy into the Assign activity like this. Note that we are using "header" attribute to refer a soap header. (Resultant process's response is shown in response.xml)
2. Create a new soap Header in a variable and assign a value to it
Let's add new soap header called "echo2" in the output variable and assign request message text (input) value as new header value. First copy will create the echo2 header and second copy will do the value assigning. (Resultant response is shown in response.xml)
3. Copying soap header from one variable to another.
Let's copy request message's echo header to output message. In the Assign activity define a copy as follow. (Resultant response is shown in response.xml)