You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ahmed Bakran <ab...@gmail.com> on 2014/12/19 00:19:36 UTC

401 using basic auth

Hi,

I am trying to invoke a soap service and am getting a 401 repeatedly using
the axis2 1.6.2 client.

If I curl or use the browser I am able to get in successfully.  Below is my
code snippet, as well as the logs.

    MyStub stub = new MyStub("http://myurl");
    HttpTransportProperties.Authenticator basicAuthentication = new
HttpTransportProperties.Authenticator();
    basicAuthentication.setUsername("username");
    basicAuthentication.setPassword("password");
    basicAuthentication.setPreemptiveAuthentication(true);

    Options options = stub._getServiceClient().getOptions();
    options.setProperty(HTTPConstants.AUTHENTICATE, basicAuthentication);

                   get_StatusResponse = stub.get_Status(requestParams);


Logs:

2014-12-18 18:07:20,737 DEBUG IAN=           [httpclient.wire.header]
(main) >> "POST /WebService_V3/WebService.asmx HTTP/1.1[\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "Content-Type: application/soap+xml; charset=UTF-8; action="
https://servicehost.com/Get_Status"[\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "User-Agent: Axis2[\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "Authorization: Basic ZSDDzb246OmF0dFJvY2tzIQ\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "Host: servicehost.com[\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "Transfer-Encoding: chunked[\r][\n]"
2014-12-18 18:07:20,751 DEBUG IAN=           [httpclient.wire.header]
(main) >> "[\r][\n]"
2014-12-18 18:07:21,106 DEBUG IAN=           [httpclient.wire.content]
(main) >> "13a[\r][\n]"
2014-12-18 18:07:21,106 DEBUG IAN=           [httpclient.wire.content]
(main) >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:Get_Status
xmlns:ns1="https://servicehost.com
"><ns1:str>hello</ns1:str><ns1:str2>123</ns1:str2></ns1:Get_Status></soapenv:Body></soapenv:Envelope>"
2014-12-18 18:07:21,107 DEBUG IAN=           [httpclient.wire.content]
(main) >> "[\r][\n]"
2014-12-18 18:07:21,107 DEBUG IAN=           [httpclient.wire.content]
(main) >> "0"
2014-12-18 18:07:21,109 DEBUG IAN=           [httpclient.wire.content]
(main) >> "[\r][\n]"
2014-12-18 18:07:21,109 DEBUG IAN=           [httpclient.wire.content]
(main) >> "[\r][\n]"
2014-12-18 18:07:21,183 DEBUG IAN=           [httpclient.wire.header]
(main) << "HTTP/1.1 401 Unauthorized[\r][\n]"
2014-12-18 18:07:21,183 DEBUG IAN=           [httpclient.wire.header]
(main) << "HTTP/1.1 401 Unauthorized[\r][\n]"
2014-12-18 18:07:21,186 DEBUG IAN=           [httpclient.wire.header]
(main) << "Cache-Control: private[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "Content-Type: text/html[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "Server: Microsoft-IIS/7.5[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "X-AspNet-Version: 4.0.30319[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "WWW-Authenticate: BASIC Realm=servicehost.com[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "X-Powered-By: ASP.NET[\r][\n]"
2014-12-18 18:07:21,187 DEBUG IAN=           [httpclient.wire.header]
(main) << "Date: Thu, 18 Dec 2014 23:07:45 GMT[\r][\n]"
2014-12-18 18:07:21,188 DEBUG IAN=           [httpclient.wire.header]
(main) << "Content-Length: 58[\r][\n]"
2014-12-18 18:07:21,188 DEBUG IAN=           [httpclient.wire.header]
(main) << "[\r][\n]"
2014-12-18 18:07:21,193 INFO  IAN=
[org.apache.commons.httpclient.auth.AuthChallengeProcessor] (main) basic
authentication scheme selected
2014-12-18 18:07:21,196 INFO  IAN=
[org.apache.commons.httpclient.HttpMethodDirector] (main) Failure
authenticating with BASIC 'servicehost.com'@servicehost.com:443
2014-12-18 18:07:21,197 DEBUG IAN=           [httpclient.wire.content]
(main) << "You do not have permission to view this directory or page."
2014-12-18 18:07:21,203 INFO  IAN=
[org.apache.axis2.transport.http.HTTPSender] (main) Unable to sendViaPost
to url[https://servicehost.com/WebService_V3/WebService.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at
org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.att.ProvisionStub.get_SIM_Status(ProvisionStub.java:12830)
at com.ingrid.ibp.isi.server.gsm.AttAdapter.getSimStatus(AttAdapter.java:41)
at
com.ingrid.ibp.isi.server.gsm.AttAdaptorTest.testGetSim(AttAdaptorTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)