Search code examples
javaapache-axisbasic-authentication

Axis 2 (1.6.1) client webservice Basic Auth


I´m trying to implement a client webservice (AXIS 2 1.6.1) in JBoss 5.1.0 GA.

I´ve generated the stubs and the first invocation (to a mockService) works fine.

Now i want to invoke my web service (without the mockService) and i need to inplement the Basic-Authentication.

I already implements the basic authentication code and i´m almost sure that there isn´t a bug in the code.

HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("userName");
basicAuth.setPassword("password");
basicAuth.setPreemptiveAuthentication(true);

stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth);

Since i can make a invocation using the SOAP UI, i strongly believe that my problem is that i haven´t set my "WWS-Password Type" and "WWS TimeToLive" (i have the same error message when i disable these properties on the SOAP-UI).

I think that i may need to put a axis2.xml in the server to put these properties but... When do i put my configuration file (in JBoss)? Or where do i define the path to this file? Or there is something else?

Thanks all.

Note: I tried unsucessfully this solution: Adding User/Password to SOAPHeader for WebService client call with AXIS2

My error is:

Exception in thread "main" org.apache.axis2.AxisFault: Internal Error (from server)
    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 myPackage.process(MyStub.java:187)

P.S- Note that the server web service communicate over https.

P.S.2 - Tks Edward


Solution

  • Just for the record, i´ve resolved the problem using the solution in Adding User/Password to SOAPHeader for WebService client call with AXIS2 .

    I had a misspelled tag (in this case, the user tag).

    Thanks a lot.