Sunday, December 23, 2007

Insert/Extract SOAP Headers in BPEL

It has been very common topic to insert and extract SOAP headers with BPEL. Lately, I was working with extracting WSSE headers in BPEL, I had to apply some tricks that made me write this BLOG entry.

Inserting Headers in BPEL Outbound:

I will try to enter three different types of headers:

1) Complex XSD element

2) Simple XSD element

3) WSSE headers - which comes out-of-box with BPEL

- First of all I defined XSD element which I want to insert in SOAP headers, e.g.

Here I have created ComplexCredentialElement as XSD Complex element and and Username and Password with XSD simple type. Here namespace is extremely important, I will insert all elements in SOAP header with "http://xmlns.oracle.com/InsertHeaderVariables" namespace. A target process will need to know namespace while extracting Headers, that's why namespace is very important in this case.
Now, in BPEL process I created variable and assigned those variable with some dummy values. You can see my BPEL process as well as source code in following figure:
Here I created variable of the header elements, and assigned dummy values to them. Now when I invoke the partnerlink, I need to specify those variable as bpelx:inputHeaderVariable, and BPEL PM will take care of inserting them when creating SOAP envelope. I believe if you have to insert some SOAP headers for enterprise wide, you can use OWSM client agent to do so, and if you haven't bought OWSM product then writing custom BPEL partnerlink interceptor would be an awesome choice rather than putting header in each partner link. Stay tuned for my blog on intercepting/hacking BPEL partnerlink!
The last one is to insert some WSSE headers through partnerlink, from security aspect I have separate blog entry for this thread: http://chintanblog.blogspot.com/2007/12/have-been-playing-around-with-ws-basic.html but here I am more interested in inserting and extracting headers using BPEL partnerlink.
I deployed this BPEL process and changed my partnerlink URL port to 1234 to test using obtunnel.bat. I started soasuite/bpel/bin/obtunnel.bat and kick-off the BPEL process, here is the intercepted request payload:
I can see my custom headers as well as wsse headers in my SOAP envelope Header, therefore it is working great!!!

Extracting Headers in BPEL in-bound:

I will try to extract three different types of headers:

1) Complex XSD element

2) Simple XSD element

3) WSSE headers

To extract headers I need to define elements which I need to extract, I created following XSD file which represent my simple and complex XSD header elements.

I also need to define wsse headers. Ideally I should download the XSD defined by OASIS for WSSE (http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd) in my project and create variable of the elements already defined in this XSD. Upon loading this XSD project, I got numourous issues so left that approach and created my own XSD element for reprsenting WSSE security header as shown below.
Now I created three variables and pass them to receive activity. BPEL PM takes care of populating them from SOAP headers...
I just deployed this process and I could see both my custom headers and wsse headers are populated nicely...
Source code can be downloaded from this link.

8 comments:

Anonymous said...

Hi --

I downloaded your source code to JDeveloper 10.1.3.3 and attempted to deploy the InsertHeaderVariables BPEL process. I received the following error:

Buildfile: C:\jdevstudio101330\jdev\mywork\InsertExtractHeaders\InsertHeaderVariables\build.xml

validateTask:
[echo]
--------------------------------------------------------------
| Validating workflow
--------------------------------------------------------------

[validateTask] Validation of workflow task definitions is completed without errors

deployProcess:
[echo]
--------------------------------------------------------------
| Deploying bpel process InsertHeaderVariables on localhost, port 8888
--------------------------------------------------------------

[deployProcess] Deploying process C:\jdevstudio101330\jdev\mywork\InsertExtractHeaders\InsertHeaderVariables\output\bpel_InsertHeaderVariables_1.0.jar

BUILD FAILED
C:\jdevstudio101330\jdev\mywork\InsertExtractHeaders\InsertHeaderVariables\build.xml:79: A problem occured while connecting to server "localhost" using port "8888": bpel_InsertHeaderVariables_1.0.jar failed to deploy. Exception message is: ORABPEL-05215
Error while loading process.
The process domain encountered the following errors while loading the process "InsertHeaderVariables" (revision "1.0"): Failed to compile classes.
Failed to compile the generated BPEL classes for "InsertHeaderVariables".
.
If you have installed a patch to the server, please check that the bpelcClasspath domain property includes the patch classes.
at com.collaxa.cube.engine.deployment.CubeProcessHolder.bind(CubeProcessHolder.java:285)
at com.collaxa.cube.engine.deployment.DeploymentManager.deployProcess(DeploymentManager.java:804)
at com.collaxa.cube.engine.deployment.DeploymentManager.deploySuitcase(DeploymentManager.java:670)
at com.collaxa.cube.ejb.impl.BPELDomainManagerBean.deploySuitcase(BPELDomainManagerBean.java:445)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:31)
at com.evermind.server.ThreadState.runAs(ThreadState.java:620)
at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:34)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
at DomainManagerBean_RemoteProxy_4bin6i8.deploySuitcase(Unknown Source)
at com.oracle.bpel.client.BPELDomainHandle.deploySuitcase(BPELDomainHandle.java:317)
at com.oracle.bpel.client.BPELDomainHandle.deployProcess(BPELDomainHandle.java:339)
at _deployHttpClientProcess._jspService(_deployHttpClientProcess.java:376)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.security.jazn.oc4j.JAZNFilter$1.run(JAZNFilter.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:410)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)


Total time: 3 seconds

From experimenting with a similar approach in my own code, the problems seems to stem from the multiple headers specified in the bpelx:inputHeaderVariable property on the Invoke activity.

What am I doing wrong?

Thanks for your time,

Paul Camann

Chintan Shah said...

Please check where your BPEL server is running, based on error it looks like you have not deployed dependent processes or they are not running at right port/hostname

pepe fernández said...

I have done something like you depict here. But when I check it in BPEL console, auditing the process, the header variable passed through from another bpel process is empty! and the assignation operation yields an error.

I performed a tcp-tunneling and everything seems to run well( the first process is sending off right the envelope message Headers and body to the second one)

Do you have some idea of what could be going on there, I am really puzzled!

Vikkee said...

I apologize for posting in this blog entry because my doubt is a general one.
I just installed SOA Suite 10.1.3.1 & i am using jDev 10.1.3.5.
I'm not able to deploy any single process. I get the following error as the previous person specified.
And i didn't installed any patch as stated below.

[deployProcess] Deploying process E:\jDeveloper\Application1\BPELProcess1\output\bpel_BPELProcess1_1.0.jar

BUILD FAILED
E:\jDeveloper\Application1\BPELProcess1\build.xml:78: A problem occured while connecting to server "localhost" using port "80": bpel_BPELProcess1_1.0.jar failed to deploy. Exception message is: ORABPEL-05215
Error while loading process.
The process domain encountered the following errors while loading the process "BPELProcess1" (revision "1.0"): null.
If you have installed a patch to the server, please check that the bpelcClasspath domain property includes the patch classes.
at com.collaxa.cube.engine.deployment.CubeProcessHolder.bind(CubeProcessHolder.java:285)
at com.collaxa.cube.engine.deployment.DeploymentManager.deployProcess(DeploymentManager.java:804)
at com.collaxa.cube.engine.deployment.DeploymentManager.deploySuitcase(DeploymentManager.java:670)
at com.collaxa.cube.ejb.impl.BPELDomainManagerBean.deploySuitcase(BPELDomainManagerBean.java:445)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.
.
.

91koff said...

Vignesh Dhakshinamoorthy:
If it helps, try to use jDeveloper 10.1.3.1 because version of jdeveloper should equals to BPEL version.

hina said...

thanks 91koff!
I had same error,
but could deploy with JDeveloper10.1.3.1.

Unknown said...

Hi Chintan,
I have next problem:
I have a JMS queue. The message in this queue are "SOAP Message" with Body and SOAP Header.
I have developed a "BPEL JMS service" with a JMS Adapter PartnerLink.I need extract SOAP Header from PartnetLink JMS Adapter, but with headerVariable it´s not work OK.

Could you help me with this problems?

Thanks a lot.
Regards.

Unknown said...

Not sure if your still looking into this. I am new to BPEL and working on jdev 10.1.3.4. My requirement is to extract WSSE headers in the BPEL process. I have downloaded your source code and deployed the ExtractHeaderBPELProject and InsertHeaderVariables process in dev environment. In one line I am getting "Bad response: 404 Not Found" when I tried to execute the process InsertHeaderVariables with some input string. I know its an older post. However let me know if you can guide me.