2

我正在使用 SOAPHandler,这是我getHeaders在客户端的方法:

@Override
public Set<QName> getHeaders() {
    String uri = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
    QName security_hdr = new QName(uri, "Security", "wsse");
    HashSet<QName> headers = new HashSet<QName>();
    headers.add(security_hdr);
    System.out.println("Headers: " + headers);
    return headers;
}

上一行中的 SystemOut 产生了这段代码,所以我确实从我的方法中返回了一些东西:

Headers: [{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security]

但是,当尝试在TCPMon中捕获请求时,我根本看不到标头。

POST /ws/server HTTP/1.1
Content-type: text/xml;charset="utf-8"
Soapaction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.6 in JDK 6
Host: 127.0.0.1:4027
Connection: keep-alive
Content-Length: 170

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:getServerName xmlns:ns2="http://ws.ronixus.com/"/></S:Body>
</S:Envelope>

知道我在这里缺少什么吗?我已经从其他回调方法中注释掉了代码,handleMessage以确保没有覆盖标题。

4

1 回答 1

0

也许在handleMessage中试试这个,只是为了确认?

SOAPHeader soapHeader = soapEnv.getHeader();

Iterator headers = soapHeader.extractAllHeaderElements();
while(headers.hasNext() ){
    SOAPHeaderElement headerElement = (SOAPHeaderElement) headers.next();

    Name name = headerElement.getElementName();
    System.out.println(name)
}
于 2013-04-17T12:28:25.357 回答