将头添加到SOAP消息中
|
我需要添加自定义的肥皂标题,例如登录
我这样做
class Foo implements SOAPHandler<SOAPMessageContext> {
public boolean handleMessage(SOAPMessageContext context) {
try {
SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
soapEnv.addHeader().addAttribute(new QName(\"login\"), \"bob\");
soapMsg.writeTo(System.out);//tracing OUT
return true;
} catch (SOAPException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@HandlerChain(file=\"handler-chain.xml\")//I describe Foo in this file
public class GreeterService
tracing out
我收到消息
<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Header login=\"bob\"/><S:Body><ns2:sayGoodbye xmlns:ns2=\"http://example.com/\"><arg0>SOAP</arg0></ns2:sayGoodbye></S:Body></S:Envelope>
带头
<S:Header login=\"bob\"/>
但是服务器没有任何标题就收到了它
<?xml version=\"1.0\" ?><S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><ns2:sayGoodbye xmlns:ns2=\"http://example.com/\"><arg0 xmlns=\"\">SOAP</arg0></ns2:sayGoodbye></S:Body></S:Envelope>
我做错了什么?
没有找到相关结果
已邀请:
1 个回复
掸牛浓疗
解决了此问题。