Spring Update SOAP Header with Two Elements

前端 未结 2 496
陌清茗
陌清茗 2020-12-22 09:46

I am using Spring-WS and WebServiceTemplate to call SOAP WebService. Currently, i am facing issue while updating SOAP header.

Below is complete structure of SOAP req

相关标签:
2条回答
  • 2020-12-22 10:27

    Had the same problem and managed to solve it, see here

    Basically You can marshal the two elements directly into the soap header like this instead of tying to use a Transformer :

    webServiceTemplate.getMarshaller().marshal(element1,soapHeader.getResult());
    webServiceTemplate.getMarshaller().marshal(element2,soapHeader.getResult());
    

    The marshaller mentioned here is a "org.springframework.oxm.jaxb.Jaxb2Marshaller" The element 1 and 2 above are the JAXB elements created using the generated Object factory class.

    0 讨论(0)
  • 2020-12-22 10:36

    Finally, resolved it !!

    I added dummy root while transformation and then removed that dummy root from SOAP Header.

    0 讨论(0)
提交回复
热议问题