0

我正在构建一个基于 Mule ESB 的中间件,实现异步 Web 服务。我有一个客户端通过 SoapUI 将 Soap 请求发送到我的 ESB 端点,该端点使用启用了 WS-Addressing 功能的 CXF Jax-ws 服务实现。我发送响应字符串“Hello”并开始处理输入参数以向具有回调 Web 服务端点的客户端做出异步回复。

该请求具有正确的 Soap 标头,带有标签 ReplyTo,其中包含客户端中回调端点的地址。

这是我的服务器 jax-ws 网络服务代码:

@WebService(serviceName = "OrderReceive")
@Addressing
public class OrderReceive {     
    public String perform(String id, long creditCardNumber, List<Product> products) {
        //Save values to process the async reply
        setSessionVariable(id,creditCardNumber,products);
        return "Hello, i will send the response soon";
    }
}

问题是我的 Web 服务正在自动响应回复地址,我无法控制响应。

是否可以拦截该响应并设置正确的主体?

为什么我的 Web 服务会自动响应?

问候

4

1 回答 1

2

这就是我喜欢stackoverflow的原因。我从来没有听说过这个!!!

您的“自动响应”可能是由 mule 中的行为引起的:

如果 mule 在 message 中检测到reply_to属性,则启动对该端点的自动响应。这是用于 jms 中的请求-回复功能,但可能会影响 http 连接器。

来源:

发送消息时自动响应

-------------------*------------------------

经过研究,我发现 ws-addressing 的正确行为是:

client -- SOAP request ( on port A ) --> server
client <-- HTTP 202 ( "Hello, i will send the response soon" HTTP body ) --- server
client <-- SOAP response ("Response is ready!!" on port B ) --- server

来源:jax-ws 2.2.8 和 ws-addressing

为了使这成为可能,我们需要:

1.- 服务器端点: mule/cxf

2.- 服务客户: soapui

3.- 回调端点:接收异步响应(我认为这是在 mule 中)

明白了这一点,关于它的官方文档是可悲的:

MULE 3.7 启用 WS-Addressing

我认为您需要 CallBack Enpoint 来创建和执行异步响应。我没有在骡子里找到任何东西:(。

这里有一些java实现的链接,没有m子:

带有 WS-Addressing 的异步 Web 服务

使用 JAX-WS 和 WS-Addressing 调用单端口异步服务

-------------------*------------------------

另一种解决方案可能是:

1.- mule/cxf 中的 Web 服务没有寻址。

2.- 内部操作方法:

public Response operation ( Request requestPayload ) {
    MuleClient client = new MuleClient(muleContext);
    client.dispatch("jms://my.queue", requestPayload , null);// this is async
    return new Response("Hello, i will send the response soon.");
}

参考:使用 Mule 客户端

3.- 创建一个 jms 入站端点监听:jms://my.queue

<flow>
    <jms:inbound-endpoint queue="my.queue" >
    <do something>
    <launch a response to client>
</flow>

这可能是:

a.- 通过电子邮件发送给客户

b.- 使用客户端发布的服务

c.- 短信通知

d.- 随便

这种方法可以更加灵活,并支持未来的疯狂需求。

如果您需要 mule cxf 服务或 jms 方面的帮助,请告诉我以帮助您!

http://jrichardsz.github.io/

于 2015-11-14T17:23:07.267 回答