Hi,
My goal is to consume a web service using Apache AXIS. This web service uses Integrated Windows Authentication.
I use IE have configured Proxy server address and Proxy server port using IE's Tools -> Internet Options -> Connections Tab -> LAN Settings -> Proxy serer.
If type the webservice endpoint address of the form http://239.271.380.120/serveme/WS.asmx in my browser then I see in my browser "You are not authorized to view this page .. HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration. Internet Information Services (IIS)" but there is another client in another network who is getting a login dialog to enter domain\\username and password when he types the web service endpoint address in the browser. This makes me think that either the so called another client is in the same domain as the web service provider and I am not.
Anway, I tried to write standalone HttpClient (I use commons-httpclient-3.0-rc3, commons-codec-1.3, commons-logging-1.0.4) program NTCredentialsClient.java like below :
NTCredentialsClient.java
------------------------------------------------------------------
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.auth.*;
import org.apache.commons.httpclient.methods.*;
public class NTCredentialsClient {
public static void main(String args[]) {
HttpClient client = new HttpClient();
NTCredentials credentials = new NTCredentials("user1", "password1", "MYDESKTOP", "domain1");
AuthScope authScope = new AuthScope("20.222.335.37", 3128);
client.getState().setCredentials(authScope, credentials);
//client.getState().setCredentials(AuthScope.ANY, credentials);
GetMethod get = new GetMethod("http://239.271.380.120/serveme/WS.asmx");
get.setDoAuthentication(true);
try {
int status = client.executeMethod(get);
System.out.println(status);
get.getResponseBodyAsStream();
// print the status and response
System.out.println(status + "\n" + get.getResponseBodyAsString());
}
catch (Exception e) {
e.printStackTrace();
}
finally {
get.releaseConnection();
}
}
}
------------------------------------------------------------------
In the above program, user1, password1, domain1 are details given by my service provider and
MYDESKTOP is my local machine name from which I am running the above program. 20.222.335.37
is my proxy server address and 3128 is my proxy server port. Now when I run the above
program I get this exception :
------------------------------------------------------------------
Aug 16, 2005 12:43:45 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception caught when processing request: Connection timed out: connect
Aug 16, 2005 12:43:46 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Aug 16, 2005 12:44:11 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception caught when processing request: Connection timed out: connect
Aug 16, 2005 12:44:11 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Aug 16, 2005 12:44:37 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception caught when processing request: Connection timed out: connect
Aug 16, 2005 12:44:37 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:79)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:121)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:704)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:382)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at NTCredentialsClient.main(NTCredentialsClient.java:28)
------------------------------------------------------------------
Can anyone please tell me whether the configurations I have made in my above client program are correct or is there anything that I am overlooking. Also, in the above program for AuthScope constructor, do I need to pass web service server adderss and port OR my local proxy address and local proxy port as constructor arguments ?
Please suggest ...
Thanks & Regards,
Kr.