Sunday, May 11, 2008

How to Manipulate SOAP Headers in BPEL

Now Web Services are the De facto standard to implement SOA for any organization. Web Services are self contained, self descriptive and open standard based. Everyone who is implementing web services needs to follow the same standards. W3C, OASIS, and WS-I standardizes these open standards. These standard can be applied to a new service as well as an existing service and it is the beauty of these standards. WS-* standards are based on the SOAP headers so you don't need to touch the web service implementation. To support these standards the BPEL specification implementation should have inbuilt capabilities to manipulate SOAP headers.

If we talk about Oracle BPEL Process Manager (Oracle's implementation of BPEL specification) it is having SOAP header manipulation capabilities through BPEL extensions. You can send or receive SOAP headers from a BPEL process using bpelx:inputHeaderVariable, bpelx:headerVariable extensions.

To send SOAP headers from the BPEL process you need to use bpelx:inputHeaderVariable extension in the invoke activity, just give a comma separated list of all the variables you want to send in the SOAP header. To receive SOAP headers you need to use bpelx:headerVariable extension in the receive activity. Once you add these extensions in the receive or invoke activity your part is over and the BPEL Process Manager will add your variables to SOAP header if you are invoking a web service or extract SOAP headers if you are using receive activity and assign SOAP headers to the specified variables.

Sending or receiving SOAP headers from Oracle BPEL is very simple, you need to create messages inside WSDL, variables in BPEL process and then need to use bpelx:inputHeaderVariable and bpelx:headerVariable extensions. See the following to understand how to add bpelx:inputHeaderVariable and bpelx:headerVariable into the invoke, receive, onMessage and reply activities respectively:

<receive name="receiveInput" partnerLink="client" portType="client:TestProcess"
operation="process" variable="inputVariable" createInstance="yes" bpelx:headerVariable="yourVariable1, yourVariable2"/>

<invoke name="Invoke_1" partnerLink="NestedSchemaTest"
portType="ns1:NestedSchemaTest" operation="process"
inputVariable="Invoke_1_process_InputVariable" outputVariable="Invoke_1_process_OutputVariable" bpelx:inputHeaderVariable="yourVariable1, yourVariable2 .."
bpelx:outputHeaderVariable="yourVariable1, yourVariable2 ..."/>

If you are invoking an asynchronous process then don't use bpelx:outputHeaderVariable extension.

<onMessage bpelx:headerVariable="variable_1 variable_2 ..." />
<reply bpelx:headerVariable="
variable_1 variable_2..." />

Deploy your BPEL process and use TCP protocol monitor or obtunnel to see the SOAP headers in the SOAP envelop. Don't forget to set the "optSoapShortcut" property to "false" otherwise you wont be able to see the SOAP headers in obtunnel or TCP monitor. From oracle 10.1.3.1 this property is not available on the BPEL control so you need to add it in the <BPEL Home>/domains/<domain>/config/domain.xml as given below:

<property id="optSoapShortcut">
<name>Optimize SOAP invocations.</name>
<value>false</value>
<comment></comment>
</property>


15 comments:

Dibya Prakash said...

Hi Dharmendra


Your post is relly gud. I need some help from you.
I am currently facing difficulties in calling an External Webservice from my BPEL Process and passing SOAP Message to it. The details are below:


1. The BPEL process, using database polling feature of DB Adapter, will get the records from the database.

2. Transform the message

3. Call the External Webservice and pass the transformed message as the input to it. However the Webservice expects the BPEL process to send SOAP headers in the input message.

I am struggling on how to put the transformed message within a SOAP envelope in the BPEL process.

Can you please guide me.


Thanks In Advance


Regards,
Dibya

Nitin said...

Hi Dharam Sir,

I have created one routing service as one sample application that demonstrates "header based routing", in which our routing service expects header data for filtering.
My issue is, how to send header data, while invoking this routing service through BPEL process?

Thanx In Advance
Nitin

Hari said...

I'm getting an error in the "Create Partner Link" dialogue when specifying an https-based wsdl url. The non-ssl wsdl url works fine, but I need it to work for ssl (https). The specific errror reads:

Error:Failed to read wsdl file at "https://serverstuff/webservice.cfc?wsdl", caused by: javax.net.ssl.SSLHandshakeException. :sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

What do I need to do to get the https wsdl to validate? I'm using jDev 10.1.3.2. When I deploy the BPEL, will I need to do anything on the app server? I've seen a lot of similar questions on this forum with no definitive answers. Also, the BPEL dev guide does not address SSL.

amrita said...

hi,

what if i have to call a service which needs a soap header for authentication details, but the service wsdl has no definition for the header itself....even if i create a header variable in BPEL and pass it as header in the 'invoke' activity, my service wsdl dosent have the definitin to accept it........can i modify the service wsdl n add a message type of header variable(created in BPEL).and then use it to call the service...


kindly help on this

honeysankar said...
This comment has been removed by the author.
honeysankar said...
This comment has been removed by the author.
honeysankar said...

hi Dharmendra,I am working on a customized flow simialr to ProcessSalesorderJMSCOnsumer and Requestor ABCS. I was getting a message with JMS message in a variable like namespace message.. Becoz of this i was not able to put a condition in my bpel flows. I put a condtion on this variable like switch inputvariable:part:OrderType='NEW' and it was failing with selection failure. How do i convert the SOAP Message Variable to Non SOAP MEssage Variable.

honeysankar said...
This comment has been removed by the author.
honeysankar said...
This comment has been removed by the author.
honeysankar said...
This comment has been removed by the author.
honeysankar said...
This comment has been removed by the author.
Santosh said...
This comment has been removed by the author.
Santosh said...

Hi Dharmendra,

I tried what you exactly explained here. I need to set custom SoapHeaders.
< soapenv : Header >
abc
xyz
1234


I created variables p1, u1, a1 of type string. Set the values using Assign activity. IN the invoke component I set the bpelx:inputHeaderVariable="p1, u1, a1". But it does not work at all. My SOA environment is 11.1.1.5.
Please let me know if I were missing some thing here.

Santosh said...

Sorry, the posting remoed the anchors. This is the header structure.
< Header >
< password > abc
< username> xyz
< API-KEY > 1234
< Header >

Appreciate your cooperation.

ManualidadesSalaOfe said...

Hi, im using invoke activity, im using header section and pass a variable vheader, but in recibe activity the variable vheader arrieved empty