Oracle BPEL 服务器:如何从 BPEL Java 调用中引发故障?

发布于 2024-11-15 09:05:28 字数 809 浏览 2 评论 0原文

我通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心的憧憬 2024-11-22 09:05:28

如果是 WSIF 绑定,则在“异常处理”下有此处的说明” 标题,但那篇文章已经很旧了。

对于 bpelx:exec (我认为),您需要捕获块内的异常并更新变量

尝试{
...做事

}
catch(异常前){

addAuditTrailEntry("异常消息:" + ex.getMessage());

setVariableData("V_CreateServiceException",...

}

}

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

try {
... do things

}
catch(Exception ex) {

addAuditTrailEntry("Exception message: " + ex.getMessage());

setVariableData("V_CreateServiceException",...

}

}

混吃等死 2024-11-22 09:05:28

只能抛出 BPELFault:

http://forums.oracle.com/forums/thread .jspa?threadID=547192

但它可以包含嵌套部分,这是“真正的”异常,可以在 Catch 块中提取并重新抛出(如果需要)。

我今天已经实现了。

陷阱:

  • Catch 块应该捕获系统异常之一,例如remoteFault。
  • RuntimeFault.wsdl 应导入 (wsdl:import) 到合作伙伴 WSDL 之一,否则将抛出一个令人讨厌的错误,指出未找到 BPELFault

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:

  • Catch block should catch one of the system exceptions, e.g. remoteFault.
  • RuntimeFault.wsdl shall be imported (wsdl:import) into one of the partner WSDLs, otherwise a nasty error saying that BPELFault is not found will be thrown

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文