HttpURLConnection:getInputStream(),!_NEWLINE_!How to supress FileNotFoundException at server error 500 ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Matthias_Lang
Posted On:   Tuesday, March 27, 2001 12:12 AM

How can I get the InputStream in the case of an HTTP server
error 500? The getInputStream() method of the class HttpURLConnection
throws a FileNotFoundException in this situation.
Background: The Soap specification enforces that the server
return a "Soap fault" as the response content in the case
of a status code 500 server error.

Re: HttpURLConnection:getInputStream(),!_NEWLINE_!How to supress FileNotFoundException at server error 500 ?

Posted By:   Tim_Rohaly  
Posted On:   Thursday, April 19, 2001 05:17 PM

This is apparently a bug in Sun's implementation of
HttpURLConnection. The HTTP specification clearly
states that a server should return an entity describing
the reason for the error (in your case, the "SOAP Fault" message
would be expected in the body of the returned document).
The only way to read this entity is through the input stream. Sun's HttpURLConnection
seems to throw an exception instead of allowing you to
read the stream.


To work around this, you can use a Socket to connect
to the HTTP server instead of using HttpURLConnection,
or better yet use a third-party HTTP implementation
like HTTPClient (search the networking FAQ for HTTPClient
and you'll find some more information and a link to
download it).

About | Sitemap | Contact