Sometimes we want to use both spring-ws and spring-mvc in one application.
However, these are two different stacks. To use them combined is a bit of a hassle, and... lest I forget, this post.
The following needs to be set in the applicationcontext:
This combined wisdom is found at this StackOverflow Article, but mostly in this code sample
<!-- To nicely support webservices from httprequests, we use the WebServiceMessageReceiverHandlerAdapter (which needs a messagefactory) --> <!-- Because we declare this, the dispatcherservlet automatically uses it... instead of the normal mvc adapter! --> <!-- To ensure that the normal mvc adapter is also loaded, we need to define it (the SimpleControllerHandlerAdapter) as well. --> <!-- Requires a message factory so we declare one --> <bean class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter"> <property name="messageFactory" ref="messageFactory" /> </bean> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /> <!-- and now we can add normal support for both mvc and sws --> <mvc:annotation-driven /> <sws:annotation-driven /> <!-- Since we want to use our own marshallers, override the default endpoint adapter, which allows us to add our own marshallers. --> <bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"> <property name="methodArgumentResolvers"> <list> <ref bean="marshallingPayloadMethodProcessor" /> </list> </property> <property name="methodReturnValueHandlers"> <list> <ref bean="marshallingPayloadMethodProcessor" /> </list> </property> </bean> <bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor"> <constructor-arg ref="xmlBeansMarshaller" /> <constructor-arg ref="xmlBeansMarshaller" /> </bean>
Reacties
Een reactie posten