Hi,
I'm following the tutorial by Rami Jaamour and trying the last thing
he wrote about setting the username and pw callback handler dynamically in
run-time, but it doesn't seem to work. Whatever I try, my callback is never
called. This is what the documentation says:
Another way to do this is to have the client application set the
username and CallbackHandler implementation programmatically instead of
client_deploy.wsdd:
...
import org.apache.axis.client.Stub;
...
Remote remote = locator.getPort(StockQuoteService.class);
Stub axisPort = (Stub)remote;
axisPort._setProperty(UsernameToken.PASSWORD_TYPE,
WSConstants.PASSWORD_DIGEST);
axisPort._setProperty(WSHandlerConstants.USER, "wss4j");
axisPort._setProperty(WSHandlerConstants.PW_CALLBACK_REF,
pwCallback);
where "pwCallback" is a reference to a PWCallback implementation. See
the Axis handler for WSS4J documentation for more details on this.
I would like to get a complete sample if that's possible. I tried
this piece of code, but the callback is never called and I get errors from
the web service about the wsse header is missing:
StockQuoteServiceService locator = new
StockQuoteServiceServiceLocator();
StockQuoteService service = locator.getStockWss01();
PWCallback pwCallback = new PWCallback();
Remote remote = locator.getPort(StockQuoteService.class);
Stub axisPort = (Stub)remote;
axisPort._setProperty(UsernameToken.PASSWORD_TYPE,
WSConstants.PASSWORD_DIGEST);
axisPort._setProperty(WSHandlerConstants.USER, "wss4j");
axisPort._setProperty(WSHandlerConstants.PW_CALLBACK_REF,
pwCallback);
System.out.println("Calling service...");
float quote = service.getQuote(args[0]);
System.out.println("stock quote service returned " + args[0]
+ ": "
+ quote);
I guess I shouldn't call service.getQuote() like that, but instead
call the remote method through the Stub, but I'm not sure how to do that.
Can anyone help me out before I spend another day in the sample code? :D
Thanks for any help!
Johan