Hi, I am using HttpClient 3.0.1 and sending a java object as a byte[].
Client Side: -------------- // sending a java object as HttpClient hc = new HttpClient(); HttpState hs = new HttpState(); hc.setState(initialState); PostMethod pm = new PostMethod(url); // serializedJavaObj as a byte[] pm.setRequestEntity(new ByteArrayRequestEntity(serializedJavaObj)); hc.executeMethod(pm); Server Side (Servlet): ---------------------- int len = httpRequest.getContentLength(); InputStream is = httpRequest.getInputStream(); byte[] b = new byte[len] ; // read the entire content in one shot is.read(b); // construct the java object from the byte[] deserialize(b) ; If the request content length is big around 25K then a java.io.StreamCorruptedException is thrown during deserialization. This only happens when the content length is big. If the stream is read using the code below then it works fine even for huge content length. InputStream is = httpRequest.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((read = bis.read(buffer)) != -1) { baos.write(buffer, 0, read); } deserialize(baos.toByteArray()); Can someone please explain the problem and is there a better way do this? Thanks in advance. This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp