Search code examples
marshallingspring-3webservicetemplate

Spring 3 webservice template for different webservice calls?


I am new to using WebserviceTemplate to make client calls.

I can use marshalSendAndReceive(request) for a single exposed WS. Within my client I need to call other WS too. In my SpringConfig.xml, the jaxbMarshaller is defined with a p:contextPath="com.acme.domain1.service1". It is my understanding that the contextpath is used to marshall the request.

So, if I need to make a call to service2 whose generated classes are under com.foo.service2, how do I do that in the same code? I was autowiring WebserviceTemplate.


Solution

  • Just add the list like

    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                     <property name="contextPaths">
                            <list>
                                    <value>com.acme.domain1.service1</value>
                                    <value>com.foo.service2</value>
                            </list>
                    </property>
    </bean>