Results 1 to 5 of 5

Thread: Replacing Spring JaxRpcPortProxyFactoryBean approach with Sprng WS

  1. #1
    Join Date
    Dec 2005
    Posts
    930

    Default Replacing Spring JaxRpcPortProxyFactoryBean approach with Sprng WS

    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:

    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 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:
    @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;
    		}
    	}
    The serviceInterface bean referred to the above xml simply looks like this:
    Code:
    public interface AlertService {
    
    	AlertResponseType alert(AlertRequestType alertRequestType) throws Exception;
    }
    Where AlertRequestType and AlertResponseType are from the Axis-generated classes.

    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
    Last edited by Alan Stewart; May 16th, 2007 at 07:30 PM. Reason: fix typo

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    The Spring-WS approach is XML message based, and not RPC based like the JaxRpcPortProxyFactoryBean. In the end this results in an approach which is more focussed on the XML than on the Java, solving many issues such as interoperability problems and versioning. Another benefit is that you can develop the external WS interface independently of the internal Java business services, so that you don't expose the internals of your application.

    So when migrating to Spring-WS, the Web Service will be cleaner as a result. However, you will probably end up with more code, but the code is very useful, IMO.

    Have you checked out the tutorial?
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Jan 2008
    Posts
    8

    Default

    Hi Alan,

    Do you remember if the webservice url was secure through username/password or just the endpoints on the webservice ? I am trying to use your code to access a secure webservice (username/password authentication) but somehow keep getting HTTP 401 error. So, I was wondering if there were any other settings you had to do to get this thing working ?
    I modified the applicationContext and Proxybean as you have shown here but will not able to get it working. Am I missing something ? Could you please help with this ?

    Thank you in advance

    -Jilani

  4. #4
    Join Date
    Dec 2005
    Posts
    930

    Default

    Do you remember if the webservice url was secure through username/password or just the endpoints on the webservice
    I believe the endpoints were secure. Not supplying a username and password did not cause a 401 error though from memory. You may have another issue. I'm using a pure Spring WS approach now, but still have the old code above in prod for that particular application. Perhaps you can post your code here.

    Alan

  5. #5
    Join Date
    Jan 2008
    Posts
    8

    Default

    Hi Alan-

    I had posted my code in this post before coming across your post

    http://forum.springframework.org/sho...868#post162868

    When I am invoking this webservice , I had placed all the classes generated by WSDL2JAVA utility from AXIS-1.4 in the classpath.

    And, when a webservice's endpoint is secure (requires username/password) instead of the entire url. can you still go and see the operations exposed by this webservice ? I am a little confused as to which approach is better and why ?

    Also, is it possible that you can post your working code snippet which uses pure Spring WS and Spring RPC approach (other than what you already have on this post) for username/password authentication ?

    Thanks

    -Jilani

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •