You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ravi Krishnamurthy <ra...@savvion.com> on 2006/05/18 17:23:32 UTC

REPOSt for help : WSS4j from dynamic webservice client

Ravi Krishnamurthy wrote:

> Hello:
> I have a dynamic webservice client using axisv 1.2. Trying to set the 
> wss4j related security headers as mentioned in 
> http://ws.apache.org/wss4j/axis.html. but I get the following error:
>
> AxisFault
>  faultCode: 
> {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
>  faultSubcode:
>  faultString: WSDoAllReceiver: Request does not contain required 
> Security header
>  faultActor:
>  faultNode:
>  faultDetail:
>     {http://xml.apache.org/axis/}hostname:chennai
>
> WSDoAllReceiver: Request does not contain required Security header..
>
>
> But on adding the Daxis.ClientConfigFile=client_deploy.wsdd it works fine.
>
> Could someone help me what I may be doing wrong.
>
> I ahve attached both my axis client as well the password callback class.
>
> Thanks,
> Ravi
>
>------------------------------------------------------------------------
>
>
>
>import javax.xml.namespace.QName;
>import javax.xml.rpc.ParameterMode;
>
>import org.apache.axis.client.Call;
>import org.apache.axis.client.Service;
>import org.tempuri.*;
>
>
>import org.apache.ws.security.handler.WSHandlerConstants;
>import org.apache.ws.security.message.token.UsernameToken;
>import org.apache.ws.security.WSConstants;
>import samples.stock.client.PWCallback;
>
>
>public class SimpleServiceClient {
>    
>    private static String endpoint ="http://10.1.5.229:8415/axis/services/stock-wss-01";
>    public static void main(String[] args) throws Exception{
>        call1();
>    }
>    
>    public static void call1(){
>        try{
>            Service  service = new Service();
>            Call     _call    = (Call)(service.createCall());
>            
>            _call.setProperty(UsernameToken.PASSWORD_TYPE, WSConstants.PASSWORD_DIGEST);
>            _call.setProperty(WSHandlerConstants.USER, "wss4j");
>            _call.setProperty(WSHandlerConstants.PW_CALLBACK_REF, new PWCallback());
>            
>            
>            _call.setSOAPActionURI("");
>            _call.setOperationStyle(org.apache.axis.constants.Style.DOCUMENT);
>            _call.setTargetEndpointAddress( new java.net.URL(endpoint) );
>            
>            
>            _call.setOperationName(new QName("http://10.1.5.229:8415/axis/services/stock-wss-01","getQuote"));
>            _call.addParameter(new javax.xml.namespace.QName("http://stock.samples", "symbol"),new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"),ParameterMode.IN);
>            
>            _call.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "float"));
>            _call.setReturnClass(float.class);
>            _call.setReturnQName(new javax.xml.namespace.QName("http://10.1.5.229:6415/axis/services/stock-wss-01", "getQuoteReturn"));
>            
>            
>            System.out.println(" Response from SimpleServiceClient is  is " + _call.invoke(new Object[] {"IBM"}));
>            
>            
>        }catch (Exception ex){
>            ex.printStackTrace();
>        }
>    }
>}
>  
>
>------------------------------------------------------------------------
>
>package samples.stock.client;
>import java.io.IOException;
>import javax.security.auth.callback.Callback;
>import javax.security.auth.callback.CallbackHandler;
>import javax.security.auth.callback.UnsupportedCallbackException;
>
>import org.apache.ws.security.WSConstants;
>import org.apache.ws.security.WSPasswordCallback;
>import org.apache.ws.security.handler.WSHandlerConstants;
>import org.apache.ws.security.message.token.UsernameToken;
>
>public class PWCallback implements CallbackHandler {
>    
>    public PWCallback(){
>        System.out.println(" PWCallback created ");
>    }
>    
>    public static void main(String args[]) throws Exception {
>        /*
>        StockQuoteServiceService locator = new StockQuoteServiceServiceLocator();
>        StockQuoteService service = locator.getStockWss01();
>        
>        
>        ((org.apache.axis.client.Stub)service)._setProperty(UsernameToken.PASSWORD_TYPE, WSConstants.PASSWORD_DIGEST);
>        ((org.apache.axis.client.Stub)service)._setProperty(WSHandlerConstants.USER, "wss4j");
>        ((org.apache.axis.client.Stub)service)._setProperty(WSHandlerConstants.PW_CALLBACK_REF, PWCallback.class);
>        */
>    }
>    
>    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
>        
>        
>        for (int i = 0; i < callbacks.length; i++) {
>            System.out.println(" execuiting handler : " + callbacks[i]);
>            if (callbacks[i] instanceof WSPasswordCallback) {
>                WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
>                // set the password given a username
>                System.out.println(" pc.getIdentifier is " + pc.getIdentifer());
>                if ("wss4j".equals(pc.getIdentifer())) {
>                    pc.setPassword("security");
>                }
>            } else {
>                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
>            }
>        }
>    }
>}
>  
>