Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example on Web Service Consumption using Spring if provided a WSDL

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??

like image 718
Hari Charan Avatar asked May 13 '10 09:05

Hari Charan


1 Answers

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.

like image 87
Espen Avatar answered Oct 01 '22 19:10

Espen