Hi,
I am new to HttpClient and applying version 3.x for my application. All I
know about my application which I am writing is that I have to invoke a URL
something like this http://xyz.com:8303/cics/bcwa/AG80R and I have to send
user ID and password to connect to that url which gives me back xml String.
Now when I try to write the client code to call that URL above,
HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", "Test
Client");
// pass our credentials to HttpClient, they will only be used
for
// authenticating to servers with realm "realm" on the host
// "www.verisign.com", to authenticate against
// an arbitrary realm or host change the appropriate argument to
null.
client.getState().setCredentials(
new AuthScope("http://xyz.com", 8303),
new UsernamePasswordCredentials("opensesame", "opensesame")
);
// create a GET method that reads a file over HTTPS, we're
assuming
// that this file requires basic authentication using the realm
above.
PostMethod get = new
PostMethod("http://xyz.com:8303/cics/bcwa/AG80R ");
get.setRequestEntity(new StringRequestEntity(data.toString(), null, null));
get.setDoAuthentication( true );
try {
// execute the GET
int status = client.executeMethod( get );
// print the status and response
System.out.println(status + "\n" +
get.getResponseBodyAsString());
} finally {
// release any connection resources used by the method
get.releaseConnection();
}
I get errors as below
Apr 9, 2009 12:05:13 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing
request: Connection refused: connect
Apr 9, 2009 12:05:14 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: Retrying request
Apr 9, 2009 12:05:15 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing
request: Connection refused: connect
Apr 9, 2009 12:05:15 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: Retrying request
Apr 9, 2009 12:05:16 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing
request: Connection refused: connect
Apr 9, 2009 12:05:16 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: Retrying request
Exception in thread "main" java.net.ConnectException: Connection refused:
connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:520)
at java.net.Socket.connect(Socket.java:470)
at java.net.Socket.<init>(Socket.java:367)
at java.net.Socket.<init>(Socket.java:240)
at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at com.http.core.client.Client.main(Client.java:67)
--
View this message in context:
http://www.nabble.com/Authentication-Help-needed.-Urgent-tp22974079p22974079.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]