B
ben
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
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