Mark Wolter wrote:
Hello,

I'm searching for some example code with an buffered post to a server via
https.
What I was able to do is:
Reading from a file to a String and send the String as RequestBody:
...
File file = new File("c:\\temp\\ReportRequest.xml");
                        
int x= fis.available();
byte b[]= new byte[x];
fis.read(b);
String content = new String(b);

post.setRequestBody(content);
...

But as this is a depracted method, I tried to read from the file via Stream:
...
File file = new File("c:\\temp\\ReportRequest.xml");

post.setRequestEntity(new InputStreamRequestEntity(new
FileInputStream(file)));

But here I'm getting the following exception:
org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing
request can not be repeated.

Mike,

Consider implementing a custom request entity that encapsulates the request body and making it repeatable . Something similar to this one:
http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/benchmark/FileRequestEntity.java

Hope this helps

Oleg
When using "post.setRequestEntity(new InputStreamRequestEntity(new
FileInputStream(file), file.length()));" the other side (the server) can not
parse the xml correctly. The error code is:
org.xml.sax.SAXParseException: Premature end of file.


Any suggestions?




Thanks!



Mark




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to