【问题标题】:Ws-Addressing feature in Mule ESBMule ESB 中的 Ws 寻址功能
【发布时间】:2015-11-12 22:21:22
【问题描述】:

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

请求具有正确的 Soap Header,带有标签 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";
    }
}

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

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

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

问候

【问题讨论】:

    标签: java mule cxf jax-ws ws-addressing


    【解决方案1】:

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

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

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

    来源:

    Automatic response when sending message

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

    经过研究,我发现 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 and ws-addressing

    要做到这一点,我们需要:

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

    2.- 服务客户:soapui

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

    明白这一点,关于它的官方文档很伤心:

    MULE 3.7 Enabling WS-Addressing

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

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

    Asynchronous web services with WS-Addressing

    Invoke a single port async service using JAX-WS and 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.");
    }
    

    参考:Using the Mule Client

    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/

    【讨论】:

      猜你喜欢
      • 2013-05-08
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 2010-10-04
      • 1970-01-01
      • 2015-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多