Spring Framework – Accessing web services using JAX-RPC (with Authentication)

In my previous post, I never mention about authentication. So, based on what I did in last post, I will show you how to provide the username and password from client.

You only need to put 2 extra properties in applicationContext.xml of your client.


<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
 "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
 <bean id="myService">
 <property name="serviceInterface" value="com.client.ImsWebservice.JaxRpcMyService" />
 <property name="wsdlDocumentUrl" value="http://localhost:8080/test/webservice/MyService?wsdl" />
 <property name="namespaceUri" value="http://ImsWebservice/" />
 <property name="serviceName" value="JaxRpcMyServiceService" />
 <property name="portName" value="MyService" />
 <property name="servicePostProcessors">
 <list>
 <bean/>
 </list>
 </property>
 <!-- two properties added for authentication: -->
 <property name="username" value="wsuser"/>
 <property name="password" value="wspwd"/>
 </bean>
</beans>

Done!

-HADZRUL-