You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Tamara Hills <t...@traversenetworks.com> on 2005/04/18 06:54:24 UTC

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... 


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

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

Posted by Ajith Ranabahu <aj...@gmail.com>.
hi,
This is something that should goto the axis user list. BTW there are 
setusername and setpassword methods in the call API.
 On 4/18/05, Tamara Hills <t...@traversenetworks.com> wrote: 
> 
> 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...
> 
> 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
> 



-- 
Ajith Ranabahu