Monday, May 18, 2009

Changing an Async BPEL to Sync (Calling WS from pl/sql)

This week I got an interesting task of calling a BPEL from PL/SQL. It seemed much easier than I initially thought. There are utilities available to do it and I got the references here and here. Initially the code as mentioned here didn't work. Then marC's blog code worked fine. One caveat to this whole exercise was this web service invocation from pl/sql only works for synchronous services. As for async services the client needs have the capability to receive a callback soap call.

Initially my bpel service was a async one and the pl/sql code though was able to invoke it was not able to recieve the callback. So I thought of changing it to synchronous. What followed was an interesting discovery. So firstly some basics, In bpel what makes a partnerlink async or sync is the role definition. For async you would see both partner role and my role, however for sync you will see only my role(for inbound) and partner role (for outbound).

I tried to change my async bpel to sync, by just removing the call back porttype/operations/bindings from wsdl, added a reply activity, changed the initiate operation to process and added a output message. From wsdl/bpel perspective everything was fine, but It didn't work. I was getting in bpel-console - Failed to get the WSDL operation definition of "process" in portType


After some googling, It seems there is a problem, after changing the operation name or async to sync, refreshing the wsdl, it might not work, the solution is to deploy a new version 2.0 - It worked for me. Then just deploy the 2.0 as 1.0 (In Jdev we can do this) - everything gets right.

Wednesday, May 06, 2009

Plain Vanilla BPEL #2 (Adapters)

I noted some of the day1 bpel issues here, there are also some interesting gotchas on the adapter side. Adapters are a big area covering various issues over file/ftp, database/aq adapters, JMS and Apps Adapters.

ftp adapter - I had used an outbound ftp adapter w/o much issues, inbound ftp adapters in cluster environments have to be made singleton, refer to this

db adapter - db adapter one can do 4 types of things 1) call stored proc 2)execute Insert/Update, Delete, Select operations 3) poll database table 4) execute custom sql

While using select operation parameters can be passed using #parametername to the generated SQL. While using custom sql XSD is automatically generated as per the SQL.

aq adapter - aqs can be created of type multi-consumers, in such cases consumer name has to be used while creating adapters to send/receive messages.

I will add more as we go along.

update on May/28/09
In the mean time a lot of adapter issues have been found, so that needs a mention here. Firstly FileAdapter/FtpAdapter, we had some good challenge around getting append to work for FtpAdapter. The format of the file was based on nxsd. We tried a bunch of things around making sure the transformation is correct to nsxd, making sure ftpadapter configuration (messagecount=1, unique filename, opaque schema) are correct, but append just didn’t work. After further debugging it turned out the ftp server didn’t support append in that particular directory. So a good learning was to test the ftp server configurations by doing simple ftp operations like put/get/app etc. from the prompt and then test from the ftpadapter.

One other learning was the schema used in ftp adpater can be opaque or xsd. If it’s opaque, we need to send a base64 encoded string. And the following is code snippet to do that, make sure your MXL is converted to string by using getContentAsString()
String inString = (String)getVariableData("XMLString");
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
String encodedStr=encoder.encode(inString.getBytes())

JMSAdpater, We had to connect weblogic JMSAdapter from OC4J and this blog had all that we need. And it worked. A good learning was we were using weblogic.jms.Connectionfactory which is a default connectionfactory, so we don’t see it in the admin console, so making the right configurations on oc4j-ra.xml and putting the right entries while creating the JMS Adapter wizard are the key points.

an erlier post on aq-jms on Weblogic.

Another day#1 issue is JCA port configuration in the adapter wsdl configuration is to use mcf (connection details as created by Jdev) or the JNDI url created in admin console. If you have both how will it behave? best thing we found is to use the one in server and not use mcf at all.


Update on Aug/19/09
DBAdapter if the mapping order is different in toplink mapping and XSLT, it throws cannot insert null error, the solution to that was to use detectomission to false in the dbadpater wsdl.

On another note, its possible to change the JNDI for outbound adapters, by using similar mechanism as per dynamic partner links, for dynamic partnerlinks here is a link.

On DBAdaper pooling, there is a distributedpolling setting for it to work in clusters.

FTPAdapter, one catch is the directory specified is relative to the user default directly after login.


update 1/7/2010
While creating nxsd for a file with header/detail structure, the file had lot of field length element separated by space, and using the wizard the lengths had to be specified, I noticed while using the ruler, you should not put the last position which is the length of the line or else it throws error. good reference here