【问题标题】:CXF webservice client, how to handle response from a called webservice?CXF webservice客户端,如何处理来自被调用webservice的响应?
【发布时间】:2011-11-21 22:54:46
【问题描述】:

我已经实现了一个在 web 应用程序中使用的 web 服务客户端(使用 Spring),这个客户端得到一个响应,其中 CXF 退出并给我一个错误消息。

错误信息是:

服务器无法识别 HTTP Header SOAPAction 的值

我发现了问题,但不知道我可以做些什么来调整我的 web 服务响应处理。

下面的 xml 响应没有任何问题。

工作正常并被接受!

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bar="http://www.dummyurl.com/service-v1.0/">
    <soapenv:Header/>
    <soapenv:Body>
        <bar:StartSessionResponse>
            <result>1</result>
        </bar:StartSessionResponse>
    </soapenv:Body>
</soapenv:Envelope>

服务实际返回:

失败并给我一个错误!

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <StartSessionResponse xmlns="www.dummyurl.com/service-v1.0/">
            <result xmlns="">1</result>
        </StartSessionResponse>
    </soap:Body>
</soap:Envelope>

据我所知,区别在于放置

xmlns="www.dummyurl.com/service-v1.0/ 元素,在成功的 xml 中它在信封中,在失败的 xml 中关于响应方法。

有没有办法说服 CXF 接受回复?还是服务返回异常结果?

【问题讨论】:

    标签: java soap cxf webservice-client


    【解决方案1】:

    假设第一个响应是正确的,服务在第二种情况下返回错误响应。

    在第一种情况下,“www.dummyurl.com/service-v1.0/”是元素的命名空间 - StartSessionResponse,结果不符合命名空间。第二种情况,StartSessionResponse 和第一个样本有相同的命名空间,但是结果的命名空间完全不同,结果取出 xmlns="" 会使 xml 保持一致。

    【讨论】:

      猜你喜欢
      • 2013-04-18
      • 2015-01-03
      • 2019-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多