views:

3520

answers:

2

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.

A: 

Interceptors can come in handy for the sort of thing you are trying to do. Take a look at the Interceptor hierarchy here: http://static.springframework.org/spring-ws/docs/1.0-m1/api/org/springframework/ws/EndpointInterceptor.html You can register an EndpointInterceptor with spring-ws and manipulate the response to your liking.

neesh
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.
hstoerr
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.
neesh
+1  A: 

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" />
Domchi
Danke, hat funktioniert!
hstoerr