Passing/Receiving HTTP header in SOA BPEL
In this example we will explore how to pass or receive the parameters from HTTP header.
We will explore below two scenarios,
To receive the HTTP header from SOAP request.
To pass the HTTP header while calling soap service.
SOA version used: 12.1.3c
To receive the HTTP header from SOAP request:
First we need to add the property “oracle.webservices.http.headers” under binding.ws in Service element in composite.xml. This property contains the comma separated parameters that we are expecting in request.
Example, ENV,VERSION.
<binding.ws port="http://xmlns.oracle.com/SOA_Learning/HTTPHeader/HTTPHeaderTest#wsdl.endpoint(httpheadertest_client_ep/HTTPHeaderTest_pt)">
<property name="oracle.webservices.http.headers">ENV,VERSION</property>
</binding.ws>
Now in BPEL source under receive activity, we need add <fromProperties> element which will copy the parameters from HTTP header to BPEL variable.
<receive name="receiveInput" partnerLink="httpheadertest_client" portType="client:HTTPHeaderTest" operation="process" variable="inputVariable" createInstance="yes">
<bpelx:fromProperties >
<bpelx:fromProperty name=" ENV" variable="var_ENV"></bpelx:fromProperty>
<bpelx:fromProperty name=" VERSION" variable="var_VERSION"></bpelx:fromProperty>
</bpelx:fromProperties>
</receive>
Create two variables name “var_ENV” and “var_VERSION” of type string.
Now for DEMO purpose we will return the parameters from HTTP header to SOAP response.
Now we can test our service from EM or SOAP UI. EM console also allow use to set the HTTP header in request.
RESPONSE:
If we see EM console, we will find below trace logs:
receiveInput
|
Similarly, for passing the parameters in HTTP Header, we need to add,
<property name="oracle.webservices.http.headers">ENV,VERSION</property>
To binding.ws under reference tag in composite.xml.
In INVOKE activity we need to use toProperties element.
<bpelx:toProperties >
<bpelx:toProperty name="ENV" variable="var_ENV">"lllf"</bpelx:toProperty>
<bpelx:toProperty name="VERSION" variable="ver_VERSION"></bpelx:toProperty>
</bpelx:toProperties>
Note:
The above properties does not work for REPLY activity as SOA does not support returning the parameter in HTTP header.
Thanks.