Example on Web Service Consumption using Spring if provided a WSDL

Hari Charan picture Hari Charan · May 13, 2010 · Viewed 25.3k times · Source

Hi Im a newbie to Spring WebServices. I would like to go through a standard example wherein the WSDL is provided as input from Provider. Now how will the client code for this WSDL looks like. Do we need to generate a stub code at client side??

Answer

Espen picture Espen · May 30, 2010

I will recommend generating the request and response objects with JAXB from the provider's XSD schemas.

You don't need to generate the service classes with Spring WS since it uses a template class to communicate against the WS server. If you're familiar with Spring JDBC or Spring JMS, the template class behaves quite similar to the JMSTemplate and JdbcTemplate classes.

Actually, the Spring WS client doesn't need the WSDL document at all! In addition to XSD schemas, you only need to set the URI property on the WebServiceTemplate bean like this example does:

<bean id="webServiceTemplate"
    class="org.springframework.ws.client.core.WebServiceTemplate">     

    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="marshaller" />
    <property name="defaultUri"
        value="http://localhost:8081/ws-demo/account-balance-service" />
</bean>

Here's a tutorial that might give you some answers.