Basic authentication with WebService and Apache Axis
In a recent project a had to access a WebService with Apache Axis with basic authentication.
In the simple case of using a WebService with Apache Axis, you have an instance of the class Call where you can set your authentication parameters:
In the simple case of using a WebService with Apache Axis, you have an instance of the class Call where you can set your authentication parameters:
Service service = new Service();With the WSDL2Java Tool and a generated ServiceLocator, it is not that obvious, how to setup basic authentication. The implementation of the Remote interface returned by the ServiceLocator extends the class Stub which has the same methods as the previous example. So the trick is to cast the remote interface to the concrete implementation:
Call call = (Call) service.createCall();
call.setUsername("myusername");
call.setPassword("mypassword");
MySample mySample = new MySampleLocator().getMySample();
((Stub) mySample).setUsername("myusername");
((Stub) mySample).setPassword("mypassword");
This article was copied from http://jroller.com/page/kriede/20050211#basic_authentication_with_webservice_and

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home