Hi Nadia, Does the WSDL you are using contain a WS-SecurityPolicy assertion that requires a UsernameToken? You are getting an error that shows that some WS-Policy requirement is not being satisfied. The way you have configured WSS4JOutInterceptor is for the old non-WS-Policy way of configuring WS-Security.
To see how to do it via WS-SecurityPolicy take a look at the following set of tests for UsernameTokens: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java?view=markup The WSDL with policies is here: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/ut/DoubleItUt.wsdl?view=markup The client configuration is here: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/ut/client/client.xml?view=markup Colm. On Fri, Dec 23, 2011 at 4:46 PM, nadia <[email protected]> wrote: > Hi to all! > I'm a begginer of web services and UsernameToken security policy !!! > > I'm trying to create a client web service using CXF 2.5.0 and when > I test it with I receive the following error inside Eclipse console: > > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: None of the > policy alternatives can be satisfied. > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke > (JaxWsClientProxy.java:156) > at $Proxy28.requestChunkedUpload(Unknown Source) > at it.racomputer.sara.services.action.proveSSL.wsCall.call > (wsCall.java:120) > at it.racomputer.sara.services.action.proveSSL.wsCall.main > (wsCall.java:135) > Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy > alternatives can be satisfied. > at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative > (EffectivePolicyImpl.java:170) > at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative > (EffectivePolicyImpl.java:163) > at org.apache.cxf.ws.policy.EffectivePolicyImpl.initialise > (EffectivePolicyImpl.java:89) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.getEffectiveClientRequestPolicy > (PolicyEngineImpl.java:202) > at org.apache.cxf.ws.policy.PolicyOutInterceptor.handle > (PolicyOutInterceptor.java:112) > at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage > (AbstractPolicyInterceptor.java:45) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept > (PhaseInterceptorChain.java:263) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:535) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:465) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:368) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:321) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke > (JaxWsClientProxy.java:134) > ... 3 more > > Even if inside my client java I have used an interceptor to set the > usernametoken, in this way: > > xxxxxx port = service.getPort(); > service.getHandlerResolver(); > org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port); > org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint(); > cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor()); > cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor()); > Map<String,Object> outProps= new HashMap<String,Object>(); > outProps.put(WSHandlerConstants.ACTION,"UsernameToken Timestamp"); > outProps.put(WSHandlerConstants.USER, "admin"); > outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT); > outProps.put > (WSHandlerConstants.USERNAME_TOKEN,ClientPasswordCallback.class.getName()); > //Set the properties on the interceptor > WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); > cxfEndpoint.getOutInterceptors().add(wssOut); > > ... > > Can anyone hel me? > Thanks, > Nadia > > -- Colm O hEigeartaigh Talend Community Coder http://coders.talend.com
