Click to See Complete Forum and Search --> : Connecting to a url with Domain, username and password


getstarted
March 9th, 2009, 01:27 PM
I am trying to access a URL(ASPX page on IIS) from Java (Weblogic). I am getting the following error.

java.io.FileNotFoundException: Response: '401: Unauthorized' for url

Here is my code;
String auth = domain + "\\" + userName ":" + password;
String encodedAuth = new BASE64Encoder().encode(auth.getBytes());
URL url = new URL(serviceURL);
URLConnection yc = url.openConnection();
yc.setRequestProperty ("Authorization", "Basic " + encodedAuth);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

TIA.

getstarted
March 10th, 2009, 07:16 PM
HttpMethodBase method = null;
try {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY,
new NTCredentials(userName, pwd, host, domain) );
System.out.println(httpServiceURL);

method = new GetMethod(httpServiceURL);
method.setDoAuthentication( true );
int status = client.executeMethod(method);
System.out.println(status + "\n" + method.getResponseBodyAsString());
}

This works fine on stand alone java application, but when I deploy it to Weblogic.. it just hangs at GetMethod. No exception, nothing..

I am trying to access a webpage that has Windows integrated security enabled.