繁体   English   中英

Java Web服务和BPEL

[英]Java Web Services and BPEL

我正在努力尝试使用此Web服务(它是与作业相关的,而不是实际的作业)。 该BPEL流程似乎提供了异步回调,但我不确定该如何使用它。 wsimport生成以下类:

> AttributedQName.java
> AttributedURI.java
> EndpointReferenceType.java
> N6368808CreditFlow.java
> N6368808CreditFlowCallback.java
> N6368808CreditFlowCallbackService.java
> N6368808CreditFlowProcessRequest.java
> N6368808CreditFlowProcessResponse.java
> N6368808CreditFlow_Service.java
> ObjectFactory.java
> ReferencePropertiesType.java
> Relationship.java ServiceNameType.java
> package-info.java

N6368808CreditFlow.java是与initiate方法的接口,我假设该方法是credit方法,因为它是唯一可用的方法,它以请求为参数。 N6368808CreditFlowCallback.java包含一个onResult方法,该方法将Response作为参数。

如何使用这项服务? 我已经能够调用该方法,但是没有得到返回的响应(由于onResult方法不执行任何操作,并且initialize方法返回void(甚至没有回调或响应),因此也不确定如何获取响应)。

到目前为止,这是我的代码:

    N6368808CreditFlow_Service service1 = new N6368808CreditFlow_Service();
    N6368808CreditFlow port = service1.getN6368808CreditFlowPort();
    N6368808CreditFlowProcessRequest rqt = new N6368808CreditFlowProcessRequest();
    rqt.setSsn("123456789");
    port.initiate(rqt);
    System.out.println("Done");

哪个根据BPEL控制台工作,并且给出“ 123456789”,我的问题是如何获得响应?

这是BPEL来源的摘录:

<sequence name="main">

<!--

 Receive input from requestor. (Note: This maps to operation defined in n6368808_CreditFlow.wsdl) 

-->

<receive name="receiveInput" partnerLink="client" portType="client:n6368808_CreditFlow" operation="initiate" variable="inputVariable" createInstance="yes"/>

<!--


          Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)


-->

- <scope name="getCreditRating">

- <sequence name="Sequence_1">

- <assign name="assign_SSN">

- <copy>

<from variable="inputVariable" part="payload" query="/client:n6368808_CreditFlowProcessRequest/client:ssn"/>

<to variable="invoke_CRS_process_InputVariable" part="payload" query="/ns1:ssn"/>

</copy>

</assign>

<invoke name="invoke_CRS" partnerLink="CreditRatingService" portType="ns1:CreditRatingService" operation="process" inputVariable="invoke_CRS_process_InputVariable" outputVariable="invoke_CRS_process_OutputVariable"/>

- <assign name="return_SSN">

- <copy>

<from variable="invoke_CRS_process_OutputVariable" part="payload" query="/ns1:rating"/>

<to variable="outputVariable" part="payload" query="/client:n6368808_CreditFlowProcessResponse/client:creditRating"/>

</copy>

</assign>

</sequence>

</scope>

<invoke name="callbackClient" partnerLink="client" portType="client:n6368808_CreditFlowCallback" operation="onResult" inputVariable="outputVariable"/>

</sequence>

</process>

您的BPEL流程确实是异步的,当接收活动使用消息时,流程实例将启动,响应是通过调用活动发送的。 为了接收响应,您的Java客户端需要打开一个实现客户端的Web服务端点:n6368808_CreditFlowCallback端口类型。 BPEL引擎如何确定回调的端点地址是特定于引擎的。 从理论上讲,伙伴链接的伙伴角色将使用接收到的消息进行初始化(即消息需要传达回调EPR)。 但是,这取决于您的BPEL引擎是否以及如何实现伙伴角色的初始化。

通常,我建议使用异步流程建模范例,因为它始终支持长时间运行的流程。 但是,如果您使用异步传输协议(例如JMS),或者绝对确定被调用的Web服务运行时间短(即整个处理不太可能花费超过HTTP连接超时的时间),则可以考虑对流程进行同步建模,通过用应答替换调用(与接收相同的partnerlink,porttype和操作)。 如有疑问,请坚持使用异步模型。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM