0 Replies Latest reply on May 13, 2003 9:05 PM by 3004

    401: Unauthorized xxx' for url: "http://xxxx/test.html"

    3004

      Hi,
      I have a web service component which go out to retrieve the content based on
      a given URL, username and password. However, I got "401 - Unauthorized xxx' back.
      I'm using WebLogic 7.0.

      In my application, here 's how I send the username and password:

      public class A { ..... // Install Authenticator Authenticator.setDefault (new
      SimpleAuthenticator(p_User, p_Password));

      long startTime = System.currentTimeMillis();

      URL url = new URL(p_UrlLocation); HttpURLConnection.setFollowRedirects(true);
      HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setInstanceFollowRedirects(false);
      con.connect();

      //InputStream is = url.openStream(); InputStream is = con.getInputStream(); ->
      I got 401 error here. ....

      }

      private class SimpleAuthenticator extends Authenticator { private String user;
      private String password;

      public SimpleAuthenticator(String p_User, String p_Password) { user = p_User;
      password = p_Password; }

      protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication
      (user, password.toCharArray()); } }

      Here is the exception:
      2003-05-13 12:41:01,168 FATAL [ExecuteThread: '12' for queue: 'default'] - FileNotFoundException
      java.io.FileNotFoundException: Response: '401: Unauthorized xxx' for url: 'http://test1:90/sample/hello1.txt'
           at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:366)
           at com.knowmadic.components.internet.FileDownload.httpDownloadWithAuth(FileDownload.java:308)
           at com.knowmadic.components.internet.FileDownload.downloadFile(FileDownload.java:101)
           at java.lang.reflect.Method.invoke(Native Method)
           at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:372)
           at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:292)
           at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:276)
           at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
           at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
           at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
           at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437)
           at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
           at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
           at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:335)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
           at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
           at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
           at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5445)
           at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:780)
           at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3105)
           at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2588)
           at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
           at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)

      Many thanks in advance.