Koutsomboris, Your servlet code appears to be causing the problem
> ServletInputStream servInStream = null; > ByteArrayOutputStream baos = null; > ByteArrayInputStream bais = null; > byte[] bufByteArray = null; > String msgIN = null; > servInStream = request.getInputStream(); > System.out.println("--->request.getContentLength() = " > +request.getContentLength()); > bufByteArray = new byte[request.getContentLength()]; > servInStream.read(bufByteArray); > msgIN = new String(bufByteArray, "UTF-8"); > bais = new ByteArrayInputStream(bufByteArray); If I interpret the words of the InputStream.html#read(byte[]) javadoc correctly, the method is supposed to read only "some number of bytes from the input stream... The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown". This method does not block until THE ENTIRE buffer is filled up, only until SOME data become available. Please someone correct me if I err. file:///C:/java/sun-jdk-1.4.2/docs/api/java/io/InputStream.html#read(byte[]) You should probably be reading the request body like that ByteArrayOutputStream outstream = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int len; while ((len = instream.read(buffer)) > 0) { outstream.write(buffer, 0, len); } outstream.close(); byte[] requestBody = outstream.toByteArray(); Hope this helps, Oleg -----Original Message----- From: Koutsomboris Tasos [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 25, 2004 14:42 To: '[EMAIL PROTECTED]' Subject: problem posting xml, with size larger than 8196 or 4319 bytes... Hello to all! Forgive me, if I have made a mistake, by posting my question to an irrelevant list, but this is my first try to use the benefits of the mailing list. I have just downloaded (from http://jakarta.apache.org/site/binindex.cgi) version 2 (final) of httpclient and I am trying to create a small tester, trying to post an xml, that I have read from a file. I am pasting the test code that mades the post (in the code, I am creating the test string , that I am willing to send, with a specific length of 10000 . The results are also the same, in case I am reading the input xml from a file ) : package com.intralot.melisa.bae.utils; import com.intralot.melisa.bae.agents.agentBase; import java.io.ByteArrayOutputStream; import com.intralot.melisa.exceptions.iLotException; import java.io.UnsupportedEncodingException; import org.exolab.castor.xml.Marshaller; import java.io.OutputStreamWriter; import org.exolab.castor.xml.CastorException; import java.io.ByteArrayInputStream; import java.io.InputStreamReader; import org.exolab.castor.types.Date; import java.io.FileOutputStream; import java.io.InputStream; import java.io.File; import java.io.FileInputStream; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.EntityEnclosingMethod; import org.apache.commons.httpclient.methods.PostMethod; public class test_post_mailinglist { public test_post_mailinglist() { } public static void main(String[] args) { test_post_mailinglist test_post1 = new test_post_mailinglist(); System.out.println("POST"); try { /////////////////////////// System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty( "org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty( "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); String stringtosend = ""; for (int kl = 0;kl<10000;kl++){ stringtosend = stringtosend + "c" ; } test_post1.SendTo("http://localhost:8080/MELISAdummy/receiver",stringtosend) ; } catch (Exception e) { System.out.println(e.toString()); } } public String SendTo(String URL, String XmlStringToSend) throws Exception { try { String strURL = URL; String input = XmlStringToSend ; PostMethod post = new PostMethod(strURL); //post.setRequestBody(new FileInputStream(new File("./input.xml"))); post.setRequestBody(input); System.out.println( "--------------------------------------------------------"); System.out.println("----------------- input.length() = " + input.length()); post.setRequestContentLength( post.CONTENT_LENGTH_AUTO ); // post.setRequestContentLength( (int) input.length() // post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED) post.setRequestHeader("Content-type", "text/xml; charset=UTF-8"); HttpClient httpclient = new HttpClient(); // Execute request httpclient.setConnectionTimeout(20000); httpclient.setTimeout(20000); int result = httpclient.executeMethod(post); System.out.println(" Response status code: " + result); System.out.print("Response CharSet--> "); System.out.println(post.getResponseCharSet()); System.out.print("Response body--> "); System.out.println(post.getResponseBodyAsString()); post.releaseConnection(); return post.getResponseBodyAsString() ; } catch(org.apache.commons.httpclient.HttpConnection$ConnectionTimeoutExceptio n e){ System.out.println("--- ConnectionTimeoutException ---"); throw e; } catch(org.apache.commons.httpclient.HttpRecoverableException e){ System.out.println("--- TimeoutException, ---"); throw e; } catch (Exception exc) { throw exc; } } } The strange thing is that if I print the results on server side, which is a servlet (I am reading the results as : ServletInputStream servInStream = null; ByteArrayOutputStream baos = null; ByteArrayInputStream bais = null; byte[] bufByteArray = null; String msgIN = null; servInStream = request.getInputStream(); System.out.println("--->request.getContentLength() = " +request.getContentLength()); bufByteArray = new byte[request.getContentLength()]; servInStream.read(bufByteArray); msgIN = new String(bufByteArray, "UTF-8"); bais = new ByteArrayInputStream(bufByteArray); System.out.println("--->bufByteArray.length = " +bufByteArray.length); System.out.println("--->msgIN.length() = " +msgIN.length()); for (int gg=0;gg<bufByteArray.length;gg++) { if (bufByteArray[gg]==0) break; System.out.print("--->byte("+gg+") = " + msgIN.charAt(gg)); } ) only first 4319 bytes include a value, although the length of received data is the same as the length of sent data (I can see these values in system.out). Any help would be useful, Tassos --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. *************************************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]