Java Client for a SOAP wsdl with basic authentication
Vishnu Austin
Greenhorn
Joined: Mar 30, 2012
Posts: 11
posted
0
Hi,
I generated the java client using axis2, for a secured wsdl. I am facing following errors on testing the client
org.apache.axis2.AxisFault: An error occurred when verifying security for the message.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at us.tx.state.txdps.records.cch.SearchServiceStub.SearchBySid(SearchServiceStub.java:1015)
at us.tx.state.txdps.records.cch.Test.testStub(Test.java:40)
at us.tx.state.txdps.records.cch.Test.main(Test.java:143)
My client code is
Also tried
Also tried
But with no success.
I tested the wsdl using SOAPUI and it works good.
Appreciate if someone could tell where I am going wrong.
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
Which version of Axis2 are you using?
Vishnu Austin
Greenhorn
Joined: Mar 30, 2012
Posts: 11
posted
0
Axis2 1.6.1
Vishnu Austin
Greenhorn
Joined: Mar 30, 2012
Posts: 11
posted
0
Below is the request response generated by SOAP
XML Request
-----------
<soapenv:Envelope xmlns:cch="http://search.txdps.state.tx.us/cch" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>abc</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123<wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">I7JFUNelmF6cViOKuY6UFw==</wsse:Nonce>
<wsu:Created>2012-05-07T13:23:16.023Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<cch:SearchBySid>
<!--Optional:-->
<cch:sid>07206390</cch:sid>
</cch:SearchBySid>
</soapenv:Body>
</soapenv:Envelope>
It looks as if you're trying to mix WSS authentication and HTTP authentication (which is what the username/password in the Options class is all about).
Have you tried configuring WSS externally by using a WSDD file, instead of doing it programmatically (which is much harder to get right)? That's what I prefer to do, as it allows you to use the same code secured and unsecured with just a change of the WSDD file.
Vishnu Austin
Greenhorn
Joined: Mar 30, 2012
Posts: 11
posted
0
Thanks Tim appreciate your response.
I tried another option using JAX-WS, and I am getting
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood
at com.sun.xml.internal.ws.protocol.soap.MUTube.createMUSOAPFaultException(MUTube.java:140)
at com.sun.xml.internal.ws.protocol.soap.ClientMUTube.processResponse(ClientMUTube.java:82)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:591)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:540)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:525)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:422)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:235)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:120)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:230)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy30.searchBySid(Unknown Source)
at Test.callWebService(Test.java:36)
The actual xml request from SOAP is
Appreciate your help.
Thanks again
Vishnu Austin
Greenhorn
Joined: Mar 30, 2012
Posts: 11
posted
0
Tim,
I made one more change...and now I am getting
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: An error occurred when verifying security for the message.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy30.searchBySid(Unknown Source)
at Test.callWebService(Test.java:36)
at Test.main(Test.java:52)
Fixed the issue, see post with label "Error: MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-s"
Priti Machhi
Greenhorn
Joined: Sep 06, 2012
Posts: 1
posted
0
How did you add the header to the client. When I try building it using the OMElement it gave me error at line
OMElement omuserName = omFactory.createOMElement(new QName("", "Username", "wsse"), null);
java.lang.IllegalArgumentException: Cannot create a prefixed element with an empty namespace name
at org.apache.axiom.om.impl.llom.OMElementImpl.handleNamespace(OMElementImpl.java:186)
at org.apache.axiom.om.impl.llom.OMElementImpl.<init>(OMElementImpl.java:161)
at org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory.createOMElement(OMLinkedListImplFactory.java:126)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Java Client for a SOAP wsdl with basic authentication