Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > 401 when getting response

Reply
Thread Tools

401 when getting response

 
 
ben
Guest
Posts: n/a
 
      08-12-2003
Hi,

I'm trying to connect to a server with HttpUrlConnection to send an
xml transaction.

When I go through the browser to the url, I get a popup box. I enter
domainname\username and the password and I'm allowed to see the page.

When I go through the code, it seems fine when I make a request but as
soon as I try to get the response, I get this :
java.io.FileNotFoundException: Response: '401: Unauthorized xxx'

Here's part of the code when I do the authentication :
--------------
String userPassword= domainName + "usernameassword";
String encoding= new sun.misc.BASE64Encoder().encode
(userPassword.getBytes()); conn.setRequestProperty("Authorization",
"Basic " + encoding);

conn.setRequestMethod("POST"); // btw, should this be a get?
--------------

I read that modifying the system properties might help but it didn't :

// System.getProperties().put( "http.proxySet", "true" );
// System.getProperties().put( "http.proxyHost", "proxyname" );
// System.getProperties().put( "http.proxyPort", "80" );

Thanks for any help you can provide!

Ben
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      08-13-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (ben) writes:
> When I go through the code, it seems fine when I make a request but as
> soon as I try to get the response, I get this :
> java.io.FileNotFoundException: Response: '401: Unauthorized xxx'


401 is the response sent by the server to challenge the
authentication. You should respond to it with the credentials. And(!)
you should provide that data without additional challenges as long as
you try to access the same protection space (but not at all if the
it changes), to avoide more 401 responses.

I guess you might want to study RFC 2617 (or any newer version, if any)
in more detail.

/Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need a url that its http response header that cotain 401 status code iMath Python 3 01-07-2013 09:09 AM
Re: Can't get around HTTP/401 response using SUDS [SOLVED] Adam Tauno Williams Python 0 03-10-2012 01:36 PM
Can't get around HTTP/401 response using SUDS Adam Tauno Williams Python 0 03-08-2012 03:44 PM
Web Service + Anon Access, but getting 401 Access Denied Error Alex Washtell via .NET 247 ASP .Net Web Services 1 04-05-2005 04:57 PM
webservice response with 401 kackson ASP .Net Web Services 0 05-08-2004 07:00 PM



Advertisments