Wednesday, April 15, 2009

Plain Vanilla BPEL

This month I had to work on couple of bpel processes and it reminded me last yr when I was working on my first bpel. Anyone starting on bpel development goes through a series of similar hick-ups to get a comfort feel on the subject.

A plain vanilla bpel is one, which takes an input xml in one format and sends another xml in a different format. So there are 3 areas of challenge that we learn about bpel on day1 namely 1)xsd of the messages 2)transformation 3)adapter details

Each area has some unique challenges, XSD needs some good understanding of XML namespaces, creating elements and types, importing/extending xsd and wsdls etc. Generally biggest challenge in bpel lies in XSLT, particularly if you have complex mapping requirements. JDev's XSL Mapper is a good starting point, It helps you visually verify both the XSDs and do some preliminary mappings, how ever if you have to use some if-else kind of logic, the mapper doesn't work, so we need to fallback on the source view and do hand coding of XSLT. XSLT is a functional language and it doesn't follow the Java coding principles, and you will first be surprised at how you cannot do many things that you easily do in Java. For example, you cannot change a variable value in XSLT, it’s like a constant. Then there would be many learning around XPATH expressions, how to pass parameters to XSLT, single quote, double quote issues etc.

Also many XSLT methods like ora:getInstanceId() or ora:getFaultString() doesn’t work in XSLT, so they have to be assigned separately to the resulting xml.

One best practice is to ‘test the XSLT outside of bpel’ and then use in bpel to avoid the endless loops of build/deploy/test the bpel. On the Console the XSLT error will also not be clear, it will give a FOTY0001 kind of code, and we have to check the actual error in server log.

One other best practice is to use addAuditTrailEntry or System.out.println to verify the variable values in bpel runtime.

I will cover the adapter issues that we face on day1 in another blog.

update7/2/10
good article on using the position() as a variable while selecting something in XSLT here

No comments: