小编Ash*_*han的帖子

无法在SOAPHandler中记录完整的SOAP消息

我在客户端创建了一个SOAPHandler来记录对服务器的传出请求,并在SOAP消息中添加了一个SOAP头.它正在记录没有头部分的传出soap xml.但是在服务器端我可以用soap记录整个消息头.

服务器端日志:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
    <Credential xmlns="http://soap.header.test.com" password="123" username="ashok"/>
</SOAP-ENV:Header>
<S:Body>
    <ns2:addNumber xmlns:ns2="http://service.ashok.com/">
        <arg0>10</arg0>
        <arg1>200</arg1>
    </ns2:addNumber>
</S:Body>
Run Code Online (Sandbox Code Playgroud)

客户端日志

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/> **NO HEADER**
<S:Body>
    <ns2:addNumber xmlns:ns2="http://service.ashok.com/">
        <arg0>10</arg0>
        <arg1>200</arg1>
    </ns2:addNumber>
</S:Body>
Run Code Online (Sandbox Code Playgroud)

我在客户端的部分SOAPHandler

if (outgoingRequest) {
    SOAPMessage message = context.getMessage();
    SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
    SOAPHeader header = envelope.getHeader();
    if (null == header) {
      header = envelope.addHeader();
    }
    QName credential = new QName("http://soap.header.test.com","Credential");
    SOAPHeaderElement headerElement = header.addHeaderElement(credential);
    QName username = new QName("username");
    headerElement.addAttribute(username, "ashok");
    QName password = new QName("password");
    headerElement.addAttribute(password, …
Run Code Online (Sandbox Code Playgroud)

java soap web-services jax-ws

4
推荐指数
1
解决办法
1775
查看次数

标签 统计

java ×1

jax-ws ×1

soap ×1

web-services ×1