Hello
all,
I am having some issues getting
Basic Authentication to work with Axis2. I generated my
client skeketon classes using WSDL2Java. The TestStub
class has a method that actually invokes the service.
Note that my service is NOT an AXIS2 hosted service, but I want to use AXIS2 for
the Client. I
keep getting the following
error:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested
exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:223)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:589)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:328)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:279)
at com.test.TestStub.CreateTest(TestStub.java:224)
at com.test.AddTest.main(AddTest.java:125)
Caused by: org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:207)
... 5 more
Caused by: org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:117)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:299)
... 6 more
- basic authentication scheme selected
- No credentials available for BASIC 'CASM'@localhost:13080
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:223)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:589)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:328)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:279)
at com.test.TestStub.CreateTest(TestStub.java:224)
at com.test.AddTest.main(AddTest.java:125)
Caused by: org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:305)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:207)
... 5 more
Caused by: org.apache.axis2.AxisFault: Axis2 transport error : Unauthorized
at org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:117)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:299)
... 6 more
- basic authentication scheme selected
- No credentials available for BASIC 'CASM'@localhost:13080
Here is a snippet of the code:
TestStub stub = new TestStub (null, "http://localhost:13080/ws");
ServiceClient sc = stub._getServiceClient();
ServiceClient sc = stub._getServiceClient();
Options options = sc.getOptions();//new
Options();
options.setTo(new EndpointReference("http://localhost:13080/ws"));
HttpTransportProperties.ProxyProperties proxy = new HttpTransportProperties().new ProxyProperties();
proxy.setProxyName("localhost");
proxy.setProxyPort(13080);
proxy.setDomain("");
proxy.setUserName("username");
proxy.setPassWord("");
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY,proxy);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
sc.setOptions(options);
stub._setServiceClient(sc);
options.setTo(new EndpointReference("http://localhost:13080/ws"));
HttpTransportProperties.ProxyProperties proxy = new HttpTransportProperties().new ProxyProperties();
proxy.setProxyName("localhost");
proxy.setProxyPort(13080);
proxy.setDomain("");
proxy.setUserName("username");
proxy.setPassWord("");
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY,proxy);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
sc.setOptions(options);
stub._setServiceClient(sc);
// invokes the Web service.
TestResponseDocument resDoc = stub.CreateTest(reqDoc);
Any thought
are appreciated.
Thanks
Joe