axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saminda Abeyruwan" <samin...@gmail.com>
Subject Re: [Axis2] client user name / password setting using Axis2.1.2
Date Mon, 05 Nov 2007 12:36:14 GMT
Latest Axis2 release is 1.3.

For https;

Ex as follow,
=====================================
public class Client {
    public static void main(String[] args) {
        try {
            XmltodayDelayedQuotesStub stub = new XmltodayDelayedQuotesStub(
                    "https://127.0.0.1:9443/services/xmltoday-delayed-quotes
");
            GetQuote quote =
                    new GetQuote();
            Options opts = stub._getServiceClient().getOptions();

            HttpTransportProperties.Authenticator basicAuthentication =
                    new HttpTransportProperties.Authenticator();
            basicAuthentication.setUsername("user1");
            basicAuthentication.setPassword("pass1");
            basicAuthentication.setPreemptiveAuthentication(true);
            opts.setProperty(
org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                             basicAuthentication);
            quote.setSymbol("IBM");
            System.setProperty("javax.net.ssl.keyStoreType", "JKS");
            System.setProperty("javax.net.ssl.keyStorePassword",
"wso2wsas");
            System.setProperty("javax.net.ssl.trustStorePassword",
"wso2wsas");
            File file = new File(

"/home/saminda/wsas/modules/distribution/target/wso2wsas-2.1-SNAPSHOT/conf",
                    "client-truststore.jks");
            System.setProperty("javax.net.ssl.trustStore",
file.getAbsolutePath());
            GetQuoteResponse response = stub.getQuote(quote);
            System.out.println(response.getGetQuoteReturn());
        } catch (AxisFault axisFault) {
            axisFault
                    .printStackTrace();  //To change body of catch statement
use File | Settings | File Templates.
        } catch (java.rmi.RemoteException e) {
            e.printStackTrace();  //To change body of catch statement use
File | Settings | File Templates.
        }
    }
}
========================================

You need to have an instance of HttpTransportProperties.Authenticator. When
filled with required credentials, base on server challenge, this will do
Basic, Digest or NTLM auth.

Thank you

Saminda

On Nov 5, 2007 7:02 AM, Raju Kullolli <rajkullo@cisco.com> wrote:

>  Hi
>
>    I'm using the Axis 2.1.2, Accessing the service over the https.
>    I need to know how to
>    a) setup user name and
>    b) password to the client code / Stub code.
>
>           I have generated stub code by using WSDL2JAVA
>
>    In Axis 1.4 , we can set
>
>     call.setUsername("user_name") ;       //org.apache.axis.client.Call
> API
>     call.setPassword("Password") ;  //org.apache.axis.client.Call
>
>    How can we achieve the same using Axis 2.1.2
>
>    Please help me in resolving this issue ASAP.
>
> Thanks
> Raju
>



-- 
Saminda Abeyruwan

Senior Software Engineer
WSO2 Inc. - www.wso2.org

Mime
View raw message