Oracle BPEL 服务器:如何从 BPEL Java 调用中引发故障?
我通过 bpelx:exec 从 BPEL 调用 java 类。如果该类能够抛出特定的错误(BPEL 从其合作伙伴链接之一获知),那么事情就会简化很多。我们将其称为 AdapterFault。 AdapterFault 是由 wsimport 及其子类 Exception 生成的。
以下是嵌入式 Java 块中的代码:
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);
当我将 java 方法声明为抛出 AdapterFault 时,BPEL 拒绝部署,并抱怨未捕获异常。看来Java标注步骤只声明了BPELFault。
我只能抛出 RuntimeException,它会转到 CatchAll 块而不是 catch(AdapterFault)。
有没有一种简单的方法可以从 java 调用中抛出已检查的错误?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果是 WSIF 绑定,则在“异常处理”下有此处的说明” 标题,但那篇文章已经很旧了。
对于 bpelx:exec (我认为),您需要捕获块内的异常并更新变量
If it is a WSIF binding there are instructions here under the "Exception Handling" heading, but that article is pretty old.
For bpelx:exec (I think) you need to catch the exception within the block and update a variable as such
只能抛出 BPELFault:
http://forums.oracle.com/forums/thread .jspa?threadID=547192
但它可以包含嵌套部分,这是“真正的”异常,可以在 Catch 块中提取并重新抛出(如果需要)。
我今天已经实现了。
陷阱:
BPELFault 相当有限,因为它只能包含代码、消息和详细信息元素,全部都是普通的文本。通过 bpelFault.setPart("myname",obj) 可以将复杂的嵌套故障类型传递给 BPEL,但我不知道如何从 BPELFault 中提取它,因为 BPEL 看不到“动态”部分。不过,代码和消息足以满足我的目的。
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.