How to add custom SOAP header in Spring WS using Axiom and XmlBeans
- by java_pill
I'm using Spring WS 1.5.8, XmlBeans for marshalling/unmarshalling and AxiomSoapMessageFactory. My app. needs a custom SOAP header. The data that needs to be in the SOAP Header is a XmlBean (i.e sessionContext in the code below). How can I construct the SOAP Header with this XmlBeans XmlObject element in it? I've mentioned the code of my WebServiceMessageCallback that I'm using and executing this code results in "'Content is not allowed in prolog.' error.
Thanks,
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
SoapMessage soapMessage = (SoapMessage) message;
SoapHeader header = soapMessage.getSoapHeader();
StringSource headerSource = new StringSource(XmlBeanUtils.getValue(sessionContext) );
transform(headerSource, header.getResult());
}