Hi, 

thanks for the quick response. Now, I'm not getting the error with the
indirectly referenced classpath 
anymore (I've donwloaded the HttpClient with dependencies instead only the 2
Jar-files...)

But I still need help in executing the PUT method with HttpClient 4. As you
wrote I checked the examples for the POST method, which are technically the
same like the PUT (if I understand it correct). But it doesn't work.

I tried the following 2 ways:



...

File fObject = new File("c:/temp/document.txt");

HttpPut put = new HttpPut("http://192.168.178.25/archive";);

FileBody filebody = new FileBody(fObject);

MultipartEntity entity = new MultipartEntity();

entity.addPart("bin", filebody);

put.setEntity(entity);
...



and



...

InputStreamEntity reqEntity = new InputStreamEntity(new
FileInputStream(fObject), -1);

reqEntity.setContentType("application/octet-stream"); //I've also tried
binary/octet-stream

reqEntity.setChunked(true);

put.setEntity(reqEntity);       

...



the code after each of the both trials (as in the examples described):



System.out.println("PUT Uri: " +put.getURI());

System.out.println("RequestLine: " +put.getRequestLine());

HttpResponse response = httpClient.execute(put);

HttpEntity resEntity = response.getEntity();

System.out.println("----------------------------------------");

System.out.println(response.getStatusLine());

if (resEntity != null) {

          System.out.println("Response content length: " +
resEntity.getContentLength());

          System.out.println("Chunked?: " + resEntity.isChunked());

}



The output of the system.outs above is the following:



PUT Uri: http://192.168.178.25/archive

RequestLine: PUT http://192.168.178.25/archive HTTP/1.1

----------------------------------------

HTTP/1.1 405 Method Not Allowed

Response content length: 0

Chunked?: false



Why it doesn't work? Or how it works correctly with the PUT? I've never
changed anything on the server's side, so the PUT successfully worked with
the HttpClient 3.1.

Does anybody know, what I'm doing wrong there?



Best regards,

Mario
-- 
View this message in context: 
http://www.nabble.com/HttpClient-3.1-PutMethod--%3E-HttpClient-4-HttpPut-tp25510057p25530427.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

Reply via email to