Hmm.  How come my message didn't show up after 2 hours..?

On Fri, Jun 27, 2008 at 10:43 AM, Yan aka. Yansheng <[EMAIL PROTECTED]>
wrote:

> Hi There,
>
> This is my first post here so I hope this is the right audience.
>
> My story: I want to replace a chunk of my code for doing I/O streaming to a
> webservice.  I use java.net.HttpURLConnection to get the InputStream and
> OutputStream, it works fine most of the time but it can get a bit flaky and
> I had to write my own retry logic.  So I decided to switch to
> jakartacommons-httpclient to see if things get better.  The problem is I
> don't seem to be able to come up with a good replacement from the httpclient
> package.
>
> Here is the method for obtaining a HttpConnection I wrote, the problem is
> the HostConfiguration returned is not populated.
>
> --------
>     private HttpConnection openConnection(URL url) throws IOException {
>         HttpMethod method = new PostMethod(url.toString());
>         HttpConnection conn = null;
>
>         // Execute the method.
>         int statusCode = getHttpClient().executeMethod (method);
>
>         if (statusCode != HttpStatus.SC_OK) {
>             method.releaseConnection();
>             throw new IOException("Unable to connect to Service: " + url);
>         }
>         else {
>             HttpConnectionManager connManager =
> client.getHttpConnectionManager();
>             conn =
> connManager.getConnection(client.getHostConfiguration());
>         }
>
>         return conn;
>     }
> -------
>
> The exception I'm getting:
>
> Exception in thread "main" java.lang.IllegalArgumentException: host
> parameter is null
>     at
> org.apache.commons.httpclient.HttpConnection.setHost(HttpConnection.java:248)
>     at
> org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout(SimpleHttpConnectionManager.java:163)
>     at
> org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnection(SimpleHttpConnectionManager.java:191)
>     at
> org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnection(SimpleHttpConnectionManager.java:108)
>     at
> amazon.wma.storage.timber.TimberServiceImpl.openConnection(MyServiceImpl.java:180)
>     ...
>
> Thanks for any help!
> Yansheng
>

Reply via email to