When working with Spring-WS, the configuration is very minimal because i have always been using annotations. Recently i have been trying to test out how to include attachements in SOAP responses and to get it to work i ended up with the following configuration.
<bean id="messageReceiver"
class="org.springframework.ws.soap.server.SoapMessageDispatcher">
<property name="endpointAdapters">
<list>
<ref bean="defaultMethodEndpointAdapter" />
</list>
</property>
</bean>
<bean id="defaultMethodEndpointAdapter"
class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
<property name="methodArgumentResolvers">
<list>
<!-- Be careful here! You might need to add more processors if you do
more than webservices! -->
<ref bean="marshallingPayloadMethodProcessor" />
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="marshallingPayloadMethodProcessor" />
</list>
</property>
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.mypackage.ws" />
<property name="mtomEnabled" value="true" />
</bean>
<bean id="marshallingPayloadMethodProcessor"
class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
<constructor-arg ref="marshaller" />
<constructor-arg ref="marshaller" />
</bean>
With the above, i can generate a SOAP response with an attachment. The problem is that i don't really understand what is going on. (i.e. what is the above configuration doing that enables the MTOM attachments.
To enable attachments:
Why do i need to configure a JAXB marshaller? All the web services that do not use attachments work fine without this configuration. All i have to do is use the @EndPoint annotation. The request/response objects for the non attachment webservice are also JAXB based so this suggests that maybe i am not doing this right (Even though it works).
What is the purpose of the messageReceiver and defaultmethodEndpointAdapter beans shown in the above configuration? The non attachment Endpoints work fine without these.
And finally can any of the above configuration be annotated instead of XML? I noticed that JAX-WS has an @MTOM annotation but could not find an equivalent for Spring-WS
Even though the services work as i expect them i am a bit worried that maybe the configuration is not right. I would like to understand why these are required and thus maybe i can make a better decision as to whether what i am doing is right or wrong.
Thanks in advance