Johan,

Herez another way to do it



import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import javax.xml.namespace.QName;



System.setProperty("axis.ClientConfigFile", "conf/ecl_client_deploy.wsdd");

Service  service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(�service endpoint goes
here�) );

call.setOperationName(new QName("uri:method", �method name goes here�)); 

call.setUsername(this.userName);

call.setProperty("action", this.action);

call.setProperty(WSConstants.PASSWORD_TYPE_ATTR,
WSConstants.PASSWORD_DIGEST);

call.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
this.passwordCallbackClass);

call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );

String str = (String)call.invoke();

If(str==results){

        System.out.println(�yaay.. I did it�);

}else{

        System.out.println(�the whole world is gonna burn in hell�);

}







You could set as many properties needed in the �call� object. For e.g. if
you want to add the encryption feature as well. You could say



call.setProperty(WSHandlerConstants.ENCRYPTION_USER, �encryption user goes
here�);

call.setProperty(WSHandlerConstants.ENC_PROP_FILE, �property file goes here
check wss4j property files for encryption�);

and you are all good to go for the encryption as well. 



 These properties are passed on to the MessageContext object which is
created. The �MessageContext� object is used by WSS4J to extract those
properties. 



Cheers



Ashok.





On Tue, 18 Jan 2005 23:34:31 +0100 [EMAIL PROTECTED] wrote:

>        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

> 

> 






Reply via email to