Spring-WS: how to use WebserviceTemplate with pre-generated SOAP-envelope

10,427

You're using ws-security in a strange way... I guess that you're trying to avoid ws-security dependancy by using pre-generated messages - for simple client might make sense, although it's definitely not by-the-book.

You can configure WebServiceTemplate to use plain XML without SOAP by setting messageFactory on WebServiceTemplate to this bean:

<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    <property name="messageFactory" ref="poxMessageFactory" />
</bean>    

<bean id="poxMessageFactory" class="org.springframework.ws.pox.dom.DomPoxMessageFactory" />
Share:
10,427

Related videos on Youtube

Hans-Peter Störr
Author by

Hans-Peter Störr

I like to develop elegant and concise solutions for complex problems. Mostly I program in Java, but I do appreciate Scala very much, since it allows for many programming styles that help with that. I prefer wisely commented code, much unit testing and functional programming with immutable objects. And I do like maths very much.

Updated on April 19, 2022

Comments

  • Hans-Peter Störr
    Hans-Peter Störr about 2 years

    Can you use a Spring-WS WebserviceTemplate for calling a webservice and avoid that it generates a SOAP-envelope? That is, the message already contains an SOAP-Envelope and I don't want that the WebserviceTemplate wraps another one around it. :-)

    The reason I want this is that I'd like to call a webservice that uses ws-security and do not want to put the ws-security stuff into the WebserviceTemplate, but just want to feed it a message with pre-generated ws-security information in the SOAP-envelope. I tried calling the method sendSourceAndReceiveToResult with a Source already contains a Soap-Envelope with the WS-Security stuff and the webservice template wraps around another Soap-Envelope and thus destroys the message.

  • Hans-Peter Störr
    Hans-Peter Störr over 15 years
    Yes, but my point is: I do not want to manipulate request and response at all! How do I avoid that the Webservice-Template does anything to it? My problem is it wraps another Soap-Envelope around the existing one.
  • neesh
    neesh over 15 years
    You cannot do that. The webservice template is SOAP centric - it assumes you want to wrap your response in a soap envelope. But in your case it seems you already have your response in a soap envelope.