java - How to remove empty header from SOAP message? -
i using spring-ws consuming webservice compains if soap envelop has empty header element. figured out default soapmessage implementation adds one.
how can remove it?
thanks in advance
http://docs.oracle.com/javaee/5/tutorial/doc/bnbhr.html:
the next line empty soap header. remove calling header.detachnode after getsoapheader call.
so here solution in plain saaj:
messagefactory messagefactory = messagefactory.newinstance("soap 1.2 protocol"); soapmessage message = messagefactory.createmessage(); message.getsoapheader().detachnode(); // suppress empty header
and here solution using spring-ws webservicemessagecallback based on this thread:
public void marshalwithsoapactionheader(myobject o) { webservicetemplate.marshalsendandreceive(o, new webservicemessagecallback() { public void dowithmessage(webservicemessage message) { saajsoapmessage saajsoapmessage = (saajsoapmessage) message; soapmessage soapmessage = saajsoapmessage.getsaajmessage(); soappart soappart = soapmessage.getsoappart(); soapenvelope envelope = soappart.getenvelope(); soapheader header = soapmessage.getsoapheader(); header.detachnode(); } }); }
Comments
Post a Comment