2013-04-17 58 views
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註釋掉了代碼,以確保沒有任何內容會覆蓋標題。

回答

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) 
} 
+0

感謝您的回覆。是的,'soapHeader'爲null。 – Jops

+0

似乎從HandlerProcessor的callBack無法成功設置(抓頭)。 – Jops

相關問題