Hi,
I've read the Spring WS Ref 1.1RC1 Doc and would like to try using Spring WS to call a web service. Curently I use the Axis 1.4 WSDL2Java program to generate my java classes, use the JaxRpcPortProxyFactoryBean, and provide a simple service interface to specify a request method to return a response object. In my Spring context I have:
The au.com.woolworths.pwrm.util.ws.PwrmPortProxyFactor yBean extends Spring's JaxRpcPortProxyFactoryBean to override the getPortStub method to set the username and password in the returned java.rmi.Remote object as follows:Code:<bean id="alertService" class="au.com.woolworths.pwrm.util.ws.PwrmPortProxyFactoryBean"> <property name="serviceFactoryClass" value="org.apache.axis.client.ServiceFactory" /> <property name="wsdlDocumentUrl" value="${ws.sharedWsdlUrl}" /> <property name="namespaceUri" value="urn:icc:shared:service:wsdl" /> <property name="username" value="${ws.sharedUsername}" /> <property name="password" value="${ws.sharedPasswd}" /> <property name="serviceInterface" value="au.com.woolworths.pwrm.util.ws.AlertService" /> <property name="serviceName" value="AlertService" /> <property name="portName" value="AlertPort" /> <property name="stub" ref="alertBindingStub" /> </bean> <bean id="alertBindingStub" class="au.com.woolworths.pwrm.util.axis.alert.AlertBindingStub"> <constructor-arg> <bean class="java.net.URL"> <constructor-arg type="java.lang.String" value="${ws.sharedBindingStubUrl}" /> </bean> </constructor-arg> <constructor-arg> <bean class="org.apache.axis.client.Service" /> </constructor-arg> </bean>
The serviceInterface bean referred to the above xml simply looks like this:Code:@Override protected Remote getPortStub() { try { stub._setProperty(Stub.USERNAME_PROPERTY, getUsername()); stub._setProperty(Stub.PASSWORD_PROPERTY, getPassword()); return (Remote) stub; } catch (Exception e) { return null; } }
Where AlertRequestType and AlertResponseType are from the Axis-generated classes.Code:public interface AlertService { AlertResponseType alert(AlertRequestType alertRequestType) throws Exception; }
That's all I had to do to be able to call this web service.
I'm unclear on how to proceed to replace this approach with Spring WS and whether the Spring WS way is cleaner and will end up with less code.
Any help or advice would be appreciated
Thanks
Alan


Reply With Quote