1
我需要在spring ws 2.0客戶端中將自定義soap頭添加到out out soap消息中。spring ws客戶端攔截器示例
我使用的是客戶端攔截如下.....
public class MyWebServiceClientInterceptor implements ClientInterceptor {
private QName qname = new QName(WEB_SERVICE_NAMESPACE, SOAP_HEADER_PART);
private String testText = "<userName>myUser</userName><role>everything</role>";
@Override
public boolean handleRequest(MessageContext context) throws WebServiceClientException {
SoapMessage soapMessage = (SoapMessage) context.getRequest();
SoapHeader soapHeader = soapMessage.getSoapHeader();
SoapHeaderElement newHeader = soapHeader.addHeaderElement(qname);
newHeader.setActorOrRole(MY_SOAP_ACTOR);
newHeader.setText(testText);
return true;
}
}
我已確認攔截器被調用,但頭似乎並沒有得到補充。我的意思是做某種「提交」將標題應用於消息?