You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jean-Noel Heyraud <jh...@e-travel.com> on 2004/01/22 14:45:21 UTC

HttpClient 2.0 rc3: java.io.StreamCorruptedException





Hi All,

I 've tried to port my application from java.io.* to httpClient. Everything
works fine (http, https), except when my client need to communication via a
proxy (no need to set user or password) using SSL.

any idea?

PostMethod postMethod = new PostMethod(URI);

file = new File(fileName);
postMethod.setRequestBody(new FileInputStream(file));
postMethod.setRequestContentLength((int)file.length());

if (connection.isProxied() && connection.isSecure()) {
      postMethod = new ConnectMethod(postMethod);
}

postMethod.execute(httpState,connection);
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
      ObjectInputStream fromETravel = new
ObjectInputStream(postMethod.getResponseBodyAsStream());


<Thu Jan 22, 2004 14:26:49 CET> [JCO.ServerThread-1] ERROR com.amadeus.sap
- [ETravelBridgeClient] InputStream does not contain a serialized object
java.io.StreamCorruptedException: InputStream does not contain a serialized
object
      at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:844)
      at java.io.ObjectInputStream.<init>(ObjectInputStream.java:163)
      at
com.amadeus.sap.client.rfc.AbstractETravelBridgeClient$ConnectionListener.sendRFC4Process(AbstractETravelBridgeClient.java:398)
      at
com.amadeus.sap.client.rfc.AbstractETravelBridgeClient$ConnectionListener.handleRequest(AbstractETravelBridgeClient.java:347)
      at com.sap.mw.jco.JCO$Server.dispatchRequest(Unknown Source)
      at com.sap.mw.jco.rfc.MiddlewareRFC$Server.nativeListen(Native
Method)
      at com.sap.mw.jco.rfc.MiddlewareRFC$Server.listen(Unknown Source)
      at com.sap.mw.jco.JCO$Server.listen(Unknown Source)
      at com.sap.mw.jco.JCO$Server.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:479)



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Re: HttpClient 2.0 rc3: java.io.StreamCorruptedException

Posted by Michael Becke <be...@u.washington.edu>.
Hi Joel,

Please take a look at the SSL guide for an example of how to use an SSL  
proxy <http://jakarta.apache.org/commons/httpclient/sslguide.html>.   
Generally speaking you do not want to manually create and use the  
ConnectMethod.  This is handled by HttpClient.execute().

Mike

On Jan 22, 2004, at 8:45 AM, Jean-Noel Heyraud wrote:
>
> Hi All,
>
> I 've tried to port my application from java.io.* to httpClient.  
> Everything
> works fine (http, https), except when my client need to communication  
> via a
> proxy (no need to set user or password) using SSL.
>
> any idea?
>
> PostMethod postMethod = new PostMethod(URI);
>
> file = new File(fileName);
> postMethod.setRequestBody(new FileInputStream(file));
> postMethod.setRequestContentLength((int)file.length());
>
> if (connection.isProxied() && connection.isSecure()) {
>       postMethod = new ConnectMethod(postMethod);
> }
>
> postMethod.execute(httpState,connection);
> if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
>       ObjectInputStream fromETravel = new
> ObjectInputStream(postMethod.getResponseBodyAsStream());
>
>
> <Thu Jan 22, 2004 14:26:49 CET> [JCO.ServerThread-1] ERROR  
> com.amadeus.sap
> - [ETravelBridgeClient] InputStream does not contain a serialized  
> object
> java.io.StreamCorruptedException: InputStream does not contain a  
> serialized
> object
>       at
> java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:844)
>       at java.io.ObjectInputStream.<init>(ObjectInputStream.java:163)
>       at
> com.amadeus.sap.client.rfc.AbstractETravelBridgeClient$ConnectionListen 
> er.sendRFC4Process(AbstractETravelBridgeClient.java:398)
>       at
> com.amadeus.sap.client.rfc.AbstractETravelBridgeClient$ConnectionListen 
> er.handleRequest(AbstractETravelBridgeClient.java:347)
>       at com.sap.mw.jco.JCO$Server.dispatchRequest(Unknown Source)
>       at com.sap.mw.jco.rfc.MiddlewareRFC$Server.nativeListen(Native
> Method)
>       at com.sap.mw.jco.rfc.MiddlewareRFC$Server.listen(Unknown Source)
>       at com.sap.mw.jco.JCO$Server.listen(Unknown Source)
>       at com.sap.mw.jco.JCO$Server.run(Unknown Source)
>       at java.lang.Thread.run(Thread.java:479)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:  
> commons-httpclient-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org