I have make 2 webservice calls, 1st call is to webservice running in Axis2 and deployed in Weblogic9.1 and the 2nd call is from the 1st webservice (running under axis2) to another webservice running under Weblogic9.1 and is using weblogic webservices. 2nd set of webservices are secured using basic http authentication.
Below is the code that accesses 2nd webservice and is written in 1st webservice implementation:
java.net.Authenticator.setDefault(new my.custom.authenticator.BasicHTTPAuthenticator("username", "password"));
MyAppWebServiceEndpoint_Impl ws = new MyAppWebServiceEndpoint_Impl("http://myserver:7001/myappws/snwebservice?WSDL");
MyAppWebServiceEndpointPort port = (MyAppWebServiceEndpointPort) ws.getMyAppWebServiceEndpointPort("username", "password");
MyAppWebServiceEndpoint_Impl and MyAppWebServiceEndpointPort is autogenerated by weblogic clientgen utility.
BasicHTTPAuthenticator is a custom authenticator which has just setters & getters and extends java.net.Authenticator.
Following the exception i am getting:
weblogic.webservice.wsdl.WSDLParseException: Failed to retrieve WSDL from http://myserver:7001/myappws/snwebservice?WSDL. Please check the URL and make sure that it is a valid XML file java.io.IOException: Server returned HTTP response code: 401 for URL: http://myserver:7001/myappws/snwebservice?WSDL at weblogic.webservice.wsdl.DefinitionFactory.createDefinition(DefinitionFactory.java:160)
When i deploy axis2 in tomcat5.5, it works fine and when i move the while axis2 to weblogic it throws the above error.
I am not familiar with WebLogic but are you sure your client code is correct? Is the line ws.getMyAppWebServiceEndpointPort("username", "password"); allowed in WebLogic client? I am not aware of any method that takes username and password as arguments. May be it is WebLogic specific.
Look at the code 401 description here. Assuming your username and password are correct, try hitting the WSDL URL in a browser. You should be asked for username and password in a popup and see what happens.
Finally, do you have to set any proxy settings when you run from WebLogic?