hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yannick PIERSON" <piers...@gmail.com>
Subject store file
Date Tue, 22 Apr 2008 07:38:08 GMT
Hi,
I'm using the library HttpClient 3.1 and I'm trying to store a file on a IIS
server.

I've ever developed a method which download a file from this server. But I'm
blocked in order to upload a file.
I've read documents from apache site and others,but must I use a servlet ?
If yes, why ? I don't understand its utility.

For that I ever done :
HttpClient client = new HttpClient();

Credentials credentials = new NTCredentials("test", "test", "homecomputer ",
"WORKGROUP");
HttpState state = client.getState();
state.setCredentials(null, null, credentials);

PutMethod put = new PutMethod("http://computer_name/webdav_acces/");
put.setRequestBody(new FileInputStream("c:\\temp\\myFileToStore.pdf"));
client.executeMethod(put);

put.releaseConnection();
-------------------------------------

Unfortunately I get this error :
java.net.SocketException: Software caused connection abort: socket write
error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
        at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
        at
org.apache.commons.httpclient.WireLogOutputStream.write(WireLogOutputStream.java:86)
        at
org.apache.commons.httpclient.methods.InputStreamRequestEntity.writeRequest(InputStreamRequestEntity.java:175)
        at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
        at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        at javaapplication1.HttpClt.myPost(HttpClt.java:79)
        at javaapplication1.Main.main(Main.java:42)

Thanks for your help,
Regards.

Yannick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message