Monday, 9 January 2012

Spring JAX-WS Client

  1. wsimport
  2. Java
  3. applicationContext.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Java:

public class MyBean
{
   private StockQuoteSoap stockQuoteService;

   public void doSomething()
   {
      String result = stockQuoteService.getQuote("ADBE");
      ...
   }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
applicationContext.xml:

<bean id="myBean" class="com.jaxwstest.spring.MyBean">
   <property name="stockQuoteService" ref="stockService" />
</bean>

<bean id="stockService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
   <property name="serviceInterface" value="com.jaxwstest.client.StockQuoteSoap" />
   <property name="wsdlDocumentUrl" value="classpath:com/jaxwstest/spring/stockquote.wsdl" /
   <property name="namespaceUri" value="http://www.webserviceX.NET/" /
   <property name="serviceName" value="StockQuote" />
   <property name="portName" value="StockQuoteSoap" />
</bean>