简体   繁体   English

CXF Web服务客户端,如何处理来自调用的Web服务的响应?

[英]CXF webservice client, how to handle response from a called webservice?

i have implemented a webservice client that is used inside a webapplication (using Spring) and this client gets a response in which CXF bailsout and gives me an error message. 我已经实现了一个Web服务客户端,该客户端在Web应用程序内部使用(使用Spring),并且此客户端收到CXF失败的响应并给我一条错误消息。

The error message is: 错误消息是:

Server did not recognize the value of HTTP Header SOAPAction 服务器无法识别HTTP标头SOAPAction的值

I have found the problem but do not know what i can do to adjust my webservice response handling. 我已经发现问题,但不知道该怎么做才能调整我的Web服务响应处理。

The xml response below works without any problems. 下面的xml响应可以正常工作。

Works and is accepted ok! 可行,可以接受!

<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>

The service actually returns: 该服务实际上返回:

Fails and gives me an error! 失败并给我一个错误!

<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>

The difference as far as i can see is in the placing of the 据我所见,区别在于

xmlns="www.dummyurl.com/service-v1.0/ element, in the success xml it is in the enveloppe, in the failed xml it is on the reponse method. xmlns =“ www.dummyurl.com/service-v1.0/元素,成功的xml中包含信封,失败的xml中包含响应方法。

Is there a way that i can convince CXF to accept the response? 有什么方法可以说服CXF接受响应吗? Or is the service giving back an abnormal result? 还是服务回馈了异常结果?

The service is giving back a wrong response in the second case, assuming that the first response is proper. 假设第一个响应是正确的,则服务在第二种情况下会返回错误响应。

In the first case "www.dummyurl.com/service-v1.0/" is the namespace of your elements - StartSessionResponse, result is not qualified with the namespace. 在第一种情况下,“ www.dummyurl.com/service-v1.0/”是元素的名称空间-StartSessionResponse,结果不符合该名称空间。 In the second case, the StartSessionResponse has the same namespace as the first sample, but the result has a different namespace altogether, taking out xmlns="" for result will make the xml consistent. 在第二种情况下,StartSessionResponse具有与第一个示例相同的名称空间,但是结果完全具有不同的名称空间,取出xmlns =“”作为结果将使xml一致。

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

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