HI Check the class path of Axis. This error generally comes when your class is not available at runtime though it was present at compile time. so set your proper classpath for Axis.
*With Regards* *Santosh Kumar* <http://www.aricent.com/> <http://www.aricent.com/> On Sun, Apr 14, 2013 at 7:52 PM, Tania Marinova <taniamm2...@yahoo.com>wrote: > I try to consume an axis 2 web service with rampart security > > I'm stuck with thsi qustion for fthree days but know I get thsi exception: > > > Exception in thread "main" org.apache.axis2.AxisFault: 1 > at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(* > Utils.java:531*) > at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(* > OutInAxisOperation.java:375*) > at org.apache.axis2.description.OutInAxisOperationClient.send(* > OutInAxisOperation.java:421*) > at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(* > OutInAxisOperation.java:229*) > at org.apache.axis2.client.OperationClient.execute(* > OperationClient.java:165*) > at org.apache.axis2.client.ServiceClient.sendReceive(* > ServiceClient.java:555*) > at org.apache.axis2.client.ServiceClient.sendReceive(* > ServiceClient.java:531*) > at tan.zltestcl.main(*zltestcl.java:55*) > > > --------------------------------------------------------------------------------------------- > Here is my PWCBhanler,.java > > *package* tan; > * > import > * org.apache.ws.security.WSPasswordCallback; > * > import > * javax.security.auth.callback.Callback;* > import > * javax.security.auth.callback.CallbackHandler;* > import > * javax.security.auth.callback.UnsupportedCallbackException; > * > import > * java.io.IOException; > * > public > * *class* PWCBHandler *implements* CallbackHandler { > *public* *void* handle(Callback[] callbacks) *throws* IOException, > UnsupportedCallbackException { > *for* (*int* i = 0; i < callbacks.length; i++) { > //When the server side need to authenticate the user > WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; > *if*(pwcb.getIdentifier().equals("bob") ) { > pwcb.setPassword( > "bobPW"); > } > } > } > } > > > > > here is my service.xml > > <service name="*ztest*" > > <module *ref*="rampart"/> > <Description> > Please Type your service description here > </Description> > <messageReceivers> > <messageReceiver *mep*="http://www.w3.org/2004/08/wsdl/in-only" > class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> > <messageReceiver *mep*="http://www.w3.org/2004/08/wsdl/in-out" > class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> > </messageReceivers> > <parameter name="ServiceClass" locked="false">tan.ztest</parameter> > <wsp:Policy wsu:Id="UTOverTransport" > xmlns:wsu=" > http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd > " > xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> > <wsp:ExactlyOne> > <wsp:All> > <sp:SignedSupportingTokens > xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> > <wsp:Policy> > <sp:UsernameToken > sp:IncludeToken=" > http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" > /> > </wsp:Policy> > </sp:SignedSupportingTokens> > <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> > <ramp:passwordCallbackClass>tan.PWCBHandler</ramp:passwordCallbackClass> > </ramp:RampartConfig> > </wsp:All> > </wsp:ExactlyOne> > </wsp:Policy> > </service> > > > > --------------------------------------------------------------------------------------------------------------------------------- > Here is my policy.xml > > <wsp:Policy wsu:Id="UTOverTransport" > xmlns:wsu=" > http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd > " > xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> > <wsp:ExactlyOne> > <wsp:All> > <sp:SignedSupportingTokens > xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> > <wsp:Policy> > <sp:UsernameToken > sp:IncludeToken=" > http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" > /> > </wsp:Policy> > </sp:SignedSupportingTokens> > <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> > *<ramp:user>*bob*</ramp:user>* > <ramp:passwordCallbackClass>tan.PWCBHandler</ramp:passwordCallbackClass> > </ramp:RampartConfig> > </wsp:All> > </wsp:ExactlyOne> > </wsp:Policy> > > > (the only difference is th added <ramp:user > paramete4r from > services.xml > > ------------------------------------------------------------------------------------------------------------------------ > > and here is my client.java > > package tan; > import org.apache.axiom.om.OMAbstractFactory; > import org.apache.axiom.om.OMElement; > import org.apache.axiom.om.OMFactory; > import org.apache.axiom.om.OMNamespace; > import org.apache.axiom.om.impl.builder.StAXOMBuilder; > import org.apache.axis2.addressing.EndpointReference; > import org.apache.axis2.client.Options; > import org.apache.axis2.client.ServiceClient; > import org.apache.axis2.context.ConfigurationContext; > import org.apache.axis2.context.ConfigurationContextFactory; > import org.apache.neethi.Policy; > import org.apache.neethi.PolicyEngine; > import org.apache.rampart.RampartMessageData; > import javax.xml.namespace.QName; > public class zltestcl { > public static void main(String[] args) throws Exception { > > if(args.length != 3) { > System.out.println("Usage: $java Client endpoint_address > client_repo_path policy_xml_path"); > } > > ConfigurationContext ctx = > ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], > null); > > ServiceClient client = new ServiceClient(ctx, null); > Options options = new Options(); > options.setAction("urn:testws"); > options.setTo(new EndpointReference(args[0])); > options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, > loadPolicy(args[2])); > client.setOptions(options); > > > client.engageModule("rampart"); > > OMElement response = client.sendReceive(getPayload("Hello world")); > > System.out.println(response); > > } > > private static Policy loadPolicy(String xmlPath) throws Exception { > StAXOMBuilder builder = new StAXOMBuilder(xmlPath); > return PolicyEngine.getPolicy(builder.getDocumentElement()); > } > > private static OMElement getPayload(String value) { > OMFactory factory = OMAbstractFactory.getOMFactory(); > OMNamespace ns = factory.createOMNamespace("http://tan%22,%22ns1/ > "); > OMElement elem = factory.createOMElement("testws", ns); > OMElement childElem = factory.createOMElement("param0", null); > childElem.setText(value); > elem.addChild(childElem); > > return elem; > } > > } > ---------------------------------------------------- > !!! note in my prvicy.xml I changd the <ramp user_ and instead of bob I > wrote mary > > and I got the exception: > No password supplied by the callback handler for user: mari > > so it seems thart my client code is reading the policy.xml > > > > >