Thanks Gerry,

 

That did the trick!  Casting the stub and letting axis encrypt for me solved it.

 

Regards,

 

-tamara

 

-----Original Message-----
From: Gerry Gao [mailto:[EMAIL PROTECTED]
Sent:
Monday, April 18, 2005 7:11 PM
To: axis-user@ws.apache.org
Subject: Re: Setting the user and pw in headers using wsdl2java generated classes

 

Hi,

 

First of all, I assume you want to use basic authentication mechanism, if so, you don't need to encode the UN and PW by yourself. Just give the plain text to AXIS. AXIS will put a HTTP header like:

Authentication: Basic 239jva0nkdfj0sdgj

in request to authenticate the client.

 

Two ways to get rid of this problem:

 

1. Cast your stub to Stub and set the un and pw:

 

    ((Stub)yourGenneratedStub).setUsername(un);

    ((Stub)yourGenneratedStub).setPassword(pw);

 

OR

2. Modify your generated stub.

You can find a method named createCall(). Set the UN and PW to the call object before it is returned.

 

Gerry

----- Original Message -----

From: Tamara Hills

Sent: Monday, April 18, 2005 11:17 PM

Subject: Setting the user and pw in headers using wsdl2java generated classes

 

Hello,

 

I'm an axis newbie.  I’ve used wsdl2java to generate some java classes from a wsdl file.  The service I’m trying to connect to requires a username and password Base64 encoded in the header. 

 

I’m not sure but I think the way to do this is through the MessageContext.  The problem I’m having is that I want to use the wsdl2java generated classes but somehow wind up with a null MessageContext ( no matter how I get to it)  Below is what I’m doing.  I've tried getting the MessageContext in many different ways and it always turns up null.  Also, I want to use the classes that wsdl2java created for me...

 

I know there is a way to use the Call object to set the user and pw, but I’m unsure of how to get to the Call object and still be able to use the Class objects that wsdl2java has generated for me.

 

 

String sUser = Base64.encode("Administrator");

String sPw = Base64.encode("password");

          

AXLAPIServiceLocator loc = new AXLAPIServiceLocator();

     AXLPort port = loc.getAXLPort();

     AxisEngine eng = loc.getEngine();

     if(eng != null)

     {

           MessageContext msgCont = eng.getCurrentMessageContext();

           //MessageContext msgCont = MessageContext.getCurrentContext();

           if(msgCont != null) {

                 msgCont.setPassword(sPw);

                 msgCont.setUsername(sUser);

           }

           else

                 System.out.println("null message context");

     }

     else

           System.out.println("null engine");

                

 

Any help is greatly appreciated.

 

Regards,

 

-tamara

 

Reply via email to