• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

java.io.IOException: Server returned HTTP response code: 401 for URL

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have been facing an issue for quite some time.

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)
at weblogic.webservice.wsdl.WSDLParser.<init>(WSDLParser.java:50)
at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:109)
at weblogic.webservice.core.rpc.ServiceImpl.<init>(ServiceImpl.java:94)
at com.mycompany.myapp.ws.client.MyAppWebServiceEndpoint_Impl.<init>(MyAppWebServiceEndpoint_Impl.java:22)
at Test.createServiceEndPoint(Test.java:72)
at Test.main(Test.java:21)

When i deploy axis2 in tomcat5.5, it works fine and when i move the while axis2 to weblogic it throws the above error.

Please provide some help.
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
    Bookmark Topic Watch Topic
  • New Topic