This page discusses how to call web services that require authentication using Stubby, a Lotus Notes database that helps you create Apache Axis "stub" files that can be used to call web services from a Lotus Notes 7.x environment. If you need more information, please see the main page.
There are three common ways to provide simple authentication for web services:
There are plenty of other ways as well (most notably by using WS-Security or a variant), although these methods are often just a variation on passing a session cookie or writing information to the SOAP Header. In any case, I'm not going to try to talk about every single way you might call a web service that requires authentication -- if for no other reason than because I simply don't have that depth of knowledge.
That being said...:
Session Cookies and Basic HTTP Authentication
Here is an example of setting a cookie and using Basic HTTP Authentication using web service client code that was generated by Stubby:
import StockInfoNamespace.*; import lotus.domino.axis.transport.http.HTTPConstants; import lotus.domino.axis.client.Call; StockInfoServiceLocator locator = new StockInfoServiceLocator(); StockInfoService service = locator.getDomino(); // to set a cookie: service._setProperty(HTTPConstants.HEADER_COOKIE, "AuthToken=abc123"); // to use Basic HTTP Authentication: service._setProperty(Call.USERNAME_PROPERTY, "user name"); service._setProperty(Call.PASSWORD_PROPERTY, "password"); service.GetStockInfo("FOO");
Authentication in the SOAP Header block
To write authentication information to the SOAP Header element of the outgoing SOAP message, please see the page on SOAP Headers.
WS-Security
I haven't tried using WSS4J to pass WS-Security info yet, but Johan Danforth has some information on his blog about using WSS4J with Axis clients:
http://weblogs.asp.net/jdanforth/archive/2005/01/22/358764.aspx
http://weblogs.asp.net/jdanforth/archive/2005/01/16/354060.aspx
With a little experimentation, that technique should be applicable to Stubby clients too.