Showing posts with label spring ws using jaxws. Show all posts
Showing posts with label spring ws using jaxws. Show all posts

Tuesday, October 8, 2013

Spring Webservice using JAXWS and JaxWsPortProxyFactoryBean

Calling WebService using JaxWsPortProxyFactoryBean


This is probably the easiest way to call the webservice . Generate the necessary classes for the webservice by using the "wsimport" utility ( have a look at http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html) . Then you can configure the bean to use the generated classes as shown
 
<bean  id="myWebservice" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="com.myws.proxy.MyTestWebService" />
<property name="wsdlDocumentUrl" value="wsdl/mytest-service.wsdl" />
<property name="namespaceUri" value="http://mycompany.com/myservice" />
<property name="serviceName" value="MyTestService" />
<property name="endpointAddress" value="http://www.test.com/webservices/mytest-service?wsdl" />
<property name="username" value="username"/>
<property name="password" value="password"/>
</bean>
Use username and password if required otherwise it can be removed . Just wire this bean to your class and call the webservice

JaxWsPortProxyFactoryBean is part of spring-web utility ,You have to include the following in your pom.xml

   <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>