You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Lalit Sahoo <la...@sonata-software.com> on 2007/02/14 13:09:16 UTC

HttpClient Class

Hi All,

 

Is it necessary to use HttpClient class?

 

If I will use following approach is there any disadvantage?

 

1. Create a connection manager

 

            MultiThreadedHttpConnectionManager connManager = new
MultiThreadedHttpConnectionManager ();

 

2. Create a host configuration

 

            HostConfiguration hostConfig = new HostConfiguration ();

 

3. Set the host and port for host configuration

 

            hostConfig.set (hostName, portNumber)

 

4. Create an HttpState instance 

 

            UsernamePasswordCredentials userCredentials = new
UsernamePasswordCredentials (userName, password);

                AuthScope authScope = new AuthScope (hostName,
portNumber, realm, authenticationScheme);

                HttpState httpState = new HttpState ();

                httpState.setCredentials (authScope, userCredentials);

 

5. Get an http connection with timeout:

 

            HttpConnection httpConnection =
connManager.getConnectionWithTimeout (hostconfig, 1000);

 

6. Create an instance of get method:

 

            

String uri = "http://172.24.19.79:7001/SimpleWebSimulator/SOAPAgent";

GetMethod getMethod = new GetMethod (uri);

 

7. To execute this method:

 

            getMethod.execute (httpState, httpConnection);

 

Can anybody help me in this regard?

 

Regards,

Lalit