Monday, December 31, 2007

Oracle BPEL Header Interceptor

I saw that BPEL interceptor has been only documented as header handler, I found it can do much more than just handling Headers. It is perfect interceptor and works just like Servlet Filter. It is sensitive part of code, because interceptor is called synchronously from main BPEL process. Any uncatched exception or time consuming delays in interceptor code will be propagated to main BPEL process.

OK, let's look at how to implement it:

We can register two different interceptor, one for request and one for response. I pretty much copied the initial part from documentation and enhance it for 10.1.3.x SOASuite. I created CustomHeaderHandler which implements HeaderHandler, and then I created two different classes InboundHandler and OutboundHandler which extends CustomHeaderHandler.

CustomHeaderHandler:

Here we can see invoke operation with Parternlink, Header, CallProperties. I have also written dumpProperties method which will dump all the properties from Map.

Here is InBound and OutBound interceptor which merely just calls CustomHedaerHandler's invoke method:

InboundHandler

OutboundHandler

I compiled all three classes and put it in bpel/system/classes directory and restarted SOASuite. I created couple of BPEL Processes to test my interceptors, I put following lines of code in bpel.xml to activate the interceptors:
Now if I look into soasuite/opmn/log/default_group~oc4j_soa~default_group~1.log, I can see the intercepted log:
Source code can be downloaded at here.

4 comments:

Unknown said...

Hi Chintan,

I love this example, especially since it reveals some inner workings of the BPEL PM. However, I noticed that in the DemoInterceptingTest1 you got the handlers the wrong way around:

<property name="requestHeaderHandlers">bpel.util.OutboundHandler</property>
<property name="responseHeaderHandlers">bpel.util.InboundHandler</property>

Or is this intentional?

Also, looking at the opmn log, the responseHeaderHandler is not executed, only the request handler. Any ideas why this is? I'm using your zip-file with no modifications.

Cheers,
Bas

Chintan Shah said...

Hello Bastiaan,

Thanks for your comment.

- First part is intentional, seems weird but I copied from original code. I tried to revert it but it was creating more mess.

- Second part, yeah seems to be some issue in 10.1.3.0, it works fine in 10.1.2. I do see problems in request handler in 10.1.3.3. Also, I do see different results when I call directly from BPEL console and from WS Java client.

I believe I did reported this bug to Oracle, but not sure about the progress.

Thanks,
Chintan

Unknown said...

Thanks. I am not getting any data in the "header" (invoke(CXPartnerLink pPartnerLink, String pOperationName,
Map payload, List header, Map pCallProps)).
I am on 10.1.3.4 version. Please let me know.

JT

Unknown said...

Hi Chintan

your info of bpel header is very nice and i am testing a sample include http hanlder because my customer want to get client ip through http handler so i am trying to several methods for take info client ip but it was not successfully. if you know method how to get ip address of client, please let me know.