I'm calling a java class from BPEL via bpelx:exec. It would simplify things a lot if the class was able to throw a specific Fault (known to BPEL from one of its partner links). Let's call it AdapterFault. AdapterFault is generated by wsimport and subclasses Exception.
Here's the code within Embedded Java block:
Object wfr = getVariableData("inputVariable","request");
Object req = getVariableData("V_CreateServiceRequest","createTNRequestPart");
somepackage.EndpointIterator it =
new somepackage.EndpointIterator();
it.setWFRequest(wfr);
it.setPlatformName("MMSC");
it.setOperationName("createTN");
it.setRequest(req);
Object reply = it.invoke();
setVariableData("V_CreateServiceResponse","createTNResponsePart",reply);
When I declare the java method as throwing the AdapterFault, the BPEL refuses to deploy complaining that Exception is uncaught. It seems that Java callout step only declares BPELFault.
I'm only able to throw RuntimeException, which goes to CatchAll block instead of catch(AdapterFault).
Is there a simple way to throw a checked Fault from a java call-out?
Only BPELFault can be thrown:
http://forums.oracle.com/forums/thread.jspa?threadID=547192
But it could include the nested part, which is the "real" exception, which can be extracted in Catch block and re-thrown, if required.
I have implemented it today.
Gotchas:
BPELFault is rather limited in that it can only have code, message and detail elements, all plain text. Passing a complex nested fault type to BPEL is possible via bpelFault.setPart("myname",obj), but I don't know how to extract it from the BPELFault, as BPEL sees no "dynamic" parts. Code and message is enough for my purposes though.