Hello I keep on getting the following exception: org.apache.axis2.AxisFault: <faultstring>Missing wsse:Security header in request</faultstring> at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:536) 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 axis2wstest.TestfnStub.testws(TestfnStub.java:198) at axis2wstest.testwscl.main(testwscl.java:60) Here is what I do: 1. I created Dynamic Web Project- with name testfn 2. I added two files: PWCBHANdler.java (code is bellow) package axis2wstest; 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.WSPasswordCallback; public class PWCBHandler implements CallbackHandler{ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for(int i = 0; i < callbacks.length;i++) { WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; if (pwcb.getIdentifier().equals("test") && pwcb.getPassword().equals("pass")) { return; } else { throw new UnsupportedCallbackException(callbacks[i],"Incorrect login/password"); } } } } AND testfn.java (code is bellow) public class testfn { public int testws(int x) { return 2*x; } } 3. I click on my source file (testfn.java)-> New - Web Sercie; 4. I downloaded rampart and copied all the jar files from lib directory of rampart distribution to testfn/WebContent/WEB- INF/lib directory. 5. I changed the testfn/WEB_INF/services/testfn/META_INF/ services.xml (engaged rampart module: and added policy: <wsp:Policy wsu:Id="UsernameToken" 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:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> <wsp:Policy> <sp:TransportToken> <wsp:Policy> <sp:HttpToken RequireClientCertificate="false"/> </wsp:Policy> </sp:TransportToken> <sp:AlgorithmSuite> <wsp:Policy> <sp:Basic256/> </wsp:Policy> </sp:AlgorithmSuite> </wsp:Policy> </sp:TransportBinding> <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> <wsp:Policy> <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient%22/> </wsp:Policy> </sp:SupportingTokens> <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"> <ramp:passwordCallbackClass>axis2wstest.PWCBHandler</ramp:passwordCallbackClass> </ramp:RampartConfig> </wsp:All> </wsp:ExactlyOne> </wsp:Policy> 6. I ran my web service on my localhost 7. Created web - service client and here is my testclint.java public static void main(String[] args) throws RemoteException { ConfigurationContext ctx; ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:/Users/gismo2/workspace/testfnclient/WebContent/WEB-INF", null); TestfnStub stub = new TestfnStub(ctx); Testws cl = new Testws(); cl.setX(5); ServiceClient client = stub._getServiceClient(); client.engageModule("rampart"); Options o = client.getOptions(); o.setPassword("pass"); o.setUserName("test"); System.setProperty("javax.net.ssl.trustStore", "/path/to/server.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password"); TestwsResponse resp = stub.testws(cl); System.out.println("Response" + resp.get_return());