1) use a client-config.wsdd (some sort of configuration file for the wsdl2java generator) and include a requestFlow handler called "my.package.AuthenticateHandler"
<deployment ..> <globalConfiguration> <requestFlow> <handler type="java:my.package.AuthenticateHandler"/> </requestFlow> ..
2) my.package.AuthenticateHandler extends BasicHandler. In the invoke() method, you get the message context.
public void invoke(MessageContext msgContext) throws AxisFault { msgContext.setUsername("myName"); msgContext.setPassword("mySecret"); }
regards Mike
Tamara Hills schrieb:
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