Answering my own question:

FooPortType binding = null;
try {
   binding = new FooServiceLocator().getfoo(new URL(url));
} catch {
  throw AxisFault.makeFault(e);
}

SOAPHeaderElement wsseSecurity = new SOAPHeaderElement(new
PrefixedQName("http://schemas.xmlsoap.org/ws/2002/12/secext";, "Security",
"wsse"));
MessageElement usernameToken = new MessageElement("","wsse:UsernameToken");
MessageElement username = new MessageElement("", "wsse:Username");
MessageElement password = new MessageElement("", "wsse:Password");
try {
   username.setObjectValue("johnsmith");
   usernameToken.addChild(username);
   password.setObjectValue("johns_passwd");
   password.addAttribute("","Type", "wsse:PasswordText");
   usernameToken.addChild(password);
   wsseSecurity.addChild(usernameToken);
}
catch (java.lang.Throwable t) {
   throw new org.apache.axis.AxisFault("Caught exception, while adding WS-Security
header.", t);
}
org.apache.axis.client.Stub s = (Stub)binding;
s.setHeader(wsseSecurity);
---------------------------------------

Got this from the FAQ.  Hope someone finds it helpful.
Bill

--- Bill Coffman <[EMAIL PROTECTED]> wrote:
> Hello all,
> 
> Thanks to all of you for making such a great product! 
> 
> I am building a standalone client to connect to a non-axis server (gSOAP based),
> but
> with WS-Security info required.  I have actually done this, but I would like some
> help in doing this the proper AXIS way. 
> 
> Is there any plans to support WSSE in AXIS?  Please let me know if there's a
> better
> way of doing this.  Below, is what I have so far.
> 
> I generate the java files from my WSDL (WSDL2Java).  This works pretty well, but
> then I want to connect to a site that requires authentication (wsse).  I have to
> tweak the generated files.  I add the below code, just before the
> setRequestHeaders(_call); setAttachments(_call); ... _call.invoke(... statements,
> in
> the XxxBindingStub.java file.  Here's the code I add:
> 
> SOAPHeaderElement wsseSecurity = new SOAPHeaderElement(new
> PrefixedQName("http://schemas.xmlsoap.org/ws/2002/12/secext";, "Security",
> "wsse"));
> MessageElement usernameToken = new MessageElement("","wsse:UsernameToken");
> MessageElement username = new MessageElement("", "wsse:Username");
> MessageElement password = new MessageElement("", "wsse:Password");
> try {
>    username.setObjectValue("johnsmith");
>    usernameToken.addChild(username);
>    password.setObjectValue("johns_passwd");
>    password.addAttribute("","Type", "wsse:PasswordText");
>    usernameToken.addChild(password);
>    wsseSecurity.addChild(usernameToken);
> }
> catch (java.lang.Throwable t) {
>    throw new org.apache.axis.AxisFault("Caught exception, while adding WS-Security
> header.", t);
> }
> _call.addHeader(wsseSecurity);
> 
> 
> Any help in cleaning up this approach would be greatly appreciated.
> 
> Thanks,
> Bill

Reply via email to