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

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -