【问题标题】:Sending Object from SOAP Handler to Web Service将对象从 SOAP 处理程序发送到 Web 服务
【发布时间】:2012-10-22 12:48:11
【问题描述】:

如何将对象从 SOAP 处理程序发送到 Web 服务?我知道我可以修改 SOAP 消息,但我正在尝试将整个 SOAP 消息发回。在 Web 服务中,我无权访问 SOAP 信封。此外,这是实现 wsdl,我无法更改作为特定 XML 类型的参数类型。所以我正在考虑在 SOAP 处理程序和 Web 服务之间使用某种并行消息传递机制。

【问题讨论】:

    标签: java xml web-services soap


    【解决方案1】:

    在 SOAP 处理程序中,

    public boolean handleMessage(SOAPMessageContext mc) {
    ...
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    SOAPMessage soapMsg = mc.getMessage();
    
    mc.put("soapMsg", out); 
    mc.setScope("soapMsg", MessageContext.Scope.APPLICATION);  
    ...
    }
    

    在网络服务中:

    MessageContext messageCtx = context.getMessageContext();
    String doc = (messageCtx.get("soapMsg")).toString();
    

    【讨论】:

    • Web Service 中的上下文在哪里定义?
    猜你喜欢
    • 2013-09-09
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    • 2012-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多