HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

View: New views
15 Messages — Rating Filter:   Alert me  

HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Folks,

I'm trying to upgrade some code from HttpClient 3.1 to version 4.

The old code that does a simple PUT in 3.1 is:

HttpClient httpClient = new HttpClient();
PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/" +fObject.getName());
RequestEntity entity = new InputStreamRequestEntity(new FileInputStream(fObject)); put.setRequestEntity(entity);       httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
put.setRequestEntity(entity);


Now, I don't know, how I can put the entity in version 4? There are no more classes for RequestEntity and InputStreamRequestEntity. I didn't find any code examples for Put, only for Get/Post, with this examples I tried to do the following:

HttpClient httpClient = new DefaultHttpClient();
HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/" +fObject.getName());
FileBody filebody = new FileBody(fObject);
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", filebody);
put.setRequestEntity(entity);



I have removed the jar files of version 3.1 and putted the 2 jar files of version 4 (also to the build-path of eclipse), but now, with the code above, I get the following error message in eclipse:
"The type org.apache.james.mime4j.message.SingleBody cannot be resolved. It is indirectly referenced from required .class files"

Can anyone give me a hint or can tell me, if I am with the code above on the right track?

Thanks in advance,
best regards and have a nice weekend!

Mario

Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by olegk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:

> Hi Folks,
>
> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>
> The old code that does a simple PUT in 3.1 is:
>
> HttpClient httpClient = new HttpClient();
> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
> +fObject.getName());
> RequestEntity entity = new InputStreamRequestEntity(new
> FileInputStream(fObject)); put.setRequestEntity(entity);      
> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
> put.setRequestEntity(entity);
>
> Now, I don't know, how I can put the entity in version 4? There are no more
> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
> code examples for Put, only for Get/Post, with this examples I tried to do
> the following:
>
> HttpClient httpClient = new DefaultHttpClient();
> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/" +fObject.getName());
> FileBody filebody = new FileBody(fObject);
> MultipartEntity entity = new MultipartEntity();
> entity.addPart("file", filebody);
> put.setRequestEntity(entity);
>
>
> I have removed the jar files of version 3.1 and putted the 2 jar files of
> version 4 (also to the build-path of eclipse), but now, with the code above,
> I get the following error message in eclipse:
> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved. It
> is indirectly referenced from required .class files"
>
> Can anyone give me a hint or can tell me, if I am with the code above on the
> right track?
>

Apparently you do not have mime4j jar on the classpath. The best way to
ensure you have all dependencies is by using Maven to manage your
project or by downloading the latest binary package with dependencies:

http://hc.apache.org/downloads.cgi

Here's an example of multipart POST:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java

PUT is virtually identical to POST from the API standpoint.

Oleg  



> Thanks in advance,
> best regards and have a nice weekend!
>
> Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Parent Message unknown Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Frans Thamura-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> 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 think POST and PUT is different, i try using poster plugin and got
that if we use push it is not sending data to REST server

F

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re:HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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

Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

Parent Message unknown Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Frans Thamura-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i am still work on this also

i want to make my swing can handle REST input.. :)

dunno how to start, but i try this code

F

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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(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-tp25510057p25530586.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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:\\document.txt");
HttpPut put = new HttpPut("http://192.168.178.25/archive");

InputStreamEntity reqEntity = new InputStreamEntity(new
FileInputStream(fObject), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true);
put.setEntity(reqEntity);
HttpEntity resEntity = response.getEntity();
...

and also with

FileBody filebody = new FileBody(fObject);
MultipartEntity entity = new MultipartEntity();
entity.addPart("bin", filebody);
put.setEntity(entity);
HttpEntity resEntity = response.getEntity();
...


Now matter what, but I get always the following message:
HTTP/1.1 405 Method Not Allowed

What I'm doing wrong? I have nothing changed on the server-side, so the
implementation of the PUT is the same. It works fine with HttpClient 3.1 but
not anymore with version 4... and I don't know, what is going wrong there.

Regards,
Mario



olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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(" document.txt ");
HttpPut put = new HttpPut(" h t t p : // 192.168.178.25 /archive ");

InputStreamEntity reqEntity = new InputStreamEntity(new
FileInputStream(fObject), -1);
reqEntity.setContentType(" binary/octet-stream ");
reqEntity.setChunked(true);
put.setEntity(reqEntity);
HttpEntity resEntity = response.getEntity();
...

and also with

FileBody filebody = new FileBody(fObject);
MultipartEntity entity = new MultipartEntity();
entity.addPart("bin", filebody);
put.setEntity(entity);
HttpEntity resEntity = response.getEntity();
...


Now matter what, but I get always the following message:
HTTP/1.1 405 Method Not Allowed

What I'm doing wrong? I have nothing changed on the server-side, so the
implementation of the PUT is the same. It works fine with HttpClient 3.1 but
not anymore with version 4... and I don't know, what is going wrong there.

Regards,
Mario



olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Mario Becker-Reinhold :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

Now matter what, but I get always the following message:
HTTP/1.1 405 Method Not Allowed

What I'm doing wrong? I have nothing changed on the server-side, so the
implementation of the PUT is the same. It works fine with HttpClient 3.1 but
not anymore with version 4... and I don't know, what is going wrong there.

Regards,
Mario



olegk wrote:

>
> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>> Hi Folks,
>>
>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>
>> The old code that does a simple PUT in 3.1 is:
>>
>> HttpClient httpClient = new HttpClient();
>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> RequestEntity entity = new InputStreamRequestEntity(new
>> FileInputStream(fObject)); put.setRequestEntity(entity);      
>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>> put.setRequestEntity(entity);
>>
>> Now, I don't know, how I can put the entity in version 4? There are no
>> more
>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>> code examples for Put, only for Get/Post, with this examples I tried to
>> do
>> the following:
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>> +fObject.getName());
>> FileBody filebody = new FileBody(fObject);
>> MultipartEntity entity = new MultipartEntity();
>> entity.addPart("file", filebody);
>> put.setRequestEntity(entity);
>>
>>
>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>> version 4 (also to the build-path of eclipse), but now, with the code
>> above,
>> I get the following error message in eclipse:
>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>> It
>> is indirectly referenced from required .class files"
>>
>> Can anyone give me a hint or can tell me, if I am with the code above on
>> the
>> right track?
>>
>
> Apparently you do not have mime4j jar on the classpath. The best way to
> ensure you have all dependencies is by using Maven to manage your
> project or by downloading the latest binary package with dependencies:
>
> http://hc.apache.org/downloads.cgi
>
> Here's an example of multipart POST:
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>
> PUT is virtually identical to POST from the API standpoint.
>
> Oleg  
>
>
>
>> Thanks in advance,
>> best regards and have a nice weekend!
>>
>> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Parent Message unknown Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Sam Crawford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd suggest posting wire logs from both your 3.1 and 4.0 implementations.

Instructions are at http://hc.apache.org/httpclient-3.x/logging.html
and http://hc.apache.org/httpcomponents-client/logging.html
respectively.

The fact that you're getting back "HTTP/1.1 405 Method Not Allowed"
suggests that the server is refusing your PUT request. A wire capture
of both the 3.1 and 4.0 will reveal the true nature of the issue.

Sam



2009/9/23 Mario Becker-Reinhold <mario.1981@...>:

>
> 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.
>
> Now matter what, but I get always the following message:
> HTTP/1.1 405 Method Not Allowed
>
> What I'm doing wrong? I have nothing changed on the server-side, so the
> implementation of the PUT is the same. It works fine with HttpClient 3.1 but
> not anymore with version 4... and I don't know, what is going wrong there.
>
> Regards,
> Mario
>
>
>
> olegk wrote:
>>
>> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>>> Hi Folks,
>>>
>>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>>
>>> The old code that does a simple PUT in 3.1 is:
>>>
>>> HttpClient httpClient = new HttpClient();
>>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>>> +fObject.getName());
>>> RequestEntity entity = new InputStreamRequestEntity(new
>>> FileInputStream(fObject)); put.setRequestEntity(entity);
>>> httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>>> put.setRequestEntity(entity);
>>>
>>> Now, I don't know, how I can put the entity in version 4? There are no
>>> more
>>> classes for RequestEntity and InputStreamRequestEntity. I didn't find any
>>> code examples for Put, only for Get/Post, with this examples I tried to
>>> do
>>> the following:
>>>
>>> HttpClient httpClient = new DefaultHttpClient();
>>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>>> +fObject.getName());
>>> FileBody filebody = new FileBody(fObject);
>>> MultipartEntity entity = new MultipartEntity();
>>> entity.addPart("file", filebody);
>>> put.setRequestEntity(entity);
>>>
>>>
>>> I have removed the jar files of version 3.1 and putted the 2 jar files of
>>> version 4 (also to the build-path of eclipse), but now, with the code
>>> above,
>>> I get the following error message in eclipse:
>>> "The type org.apache.james.mime4j.message.SingleBody cannot be resolved.
>>> It
>>> is indirectly referenced from required .class files"
>>>
>>> Can anyone give me a hint or can tell me, if I am with the code above on
>>> the
>>> right track?
>>>
>>
>> Apparently you do not have mime4j jar on the classpath. The best way to
>> ensure you have all dependencies is by using Maven to manage your
>> project or by downloading the latest binary package with dependencies:
>>
>> http://hc.apache.org/downloads.cgi
>>
>> Here's an example of multipart POST:
>>
>> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>>
>> PUT is virtually identical to POST from the API standpoint.
>>
>> Oleg
>>
>>
>>
>>> Thanks in advance,
>>> best regards and have a nice weekend!
>>>
>>> Mario
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
>> For additional commands, e-mail: httpclient-users-help@...
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/HttpClient-3.1-PutMethod--%3E-HttpClient-4-HttpPut-tp25510057p25531086.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...


Re: HttpClient 3.1 PutMethod -> HttpClient 4 HttpPut

by Ken Krugler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

And if you have access to the server logs, that's also often very  
useful.

-- Ken

On Sep 23, 2009, at 8:31am, Sam Crawford wrote:

> I'd suggest posting wire logs from both your 3.1 and 4.0  
> implementations.
>
> Instructions are at http://hc.apache.org/httpclient-3.x/logging.html
> and http://hc.apache.org/httpcomponents-client/logging.html
> respectively.
>
> The fact that you're getting back "HTTP/1.1 405 Method Not Allowed"
> suggests that the server is refusing your PUT request. A wire capture
> of both the 3.1 and 4.0 will reveal the true nature of the issue.
>
> Sam
>
>
>
> 2009/9/23 Mario Becker-Reinhold <mario.1981@...>:
>>
>> 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.
>>
>> Now matter what, but I get always the following message:
>> HTTP/1.1 405 Method Not Allowed
>>
>> What I'm doing wrong? I have nothing changed on the server-side, so  
>> the
>> implementation of the PUT is the same. It works fine with  
>> HttpClient 3.1 but
>> not anymore with version 4... and I don't know, what is going wrong  
>> there.
>>
>> Regards,
>> Mario
>>
>>
>>
>> olegk wrote:
>>>
>>> On Fri, 2009-09-18 at 07:48 -0700, Mario Becker-Reinhold wrote:
>>>> Hi Folks,
>>>>
>>>> I'm trying to upgrade some code from HttpClient 3.1 to version 4.
>>>>
>>>> The old code that does a simple PUT in 3.1 is:
>>>>
>>>> HttpClient httpClient = new HttpClient();
>>>> PutMethod put = new PutMethod(this.getArchiveURL_Put()+ "/"
>>>> +fObject.getName());
>>>> RequestEntity entity = new InputStreamRequestEntity(new
>>>> FileInputStream(fObject)); put.setRequestEntity(entity);
>>>> httpClient
>>>> .getHttpConnectionManager().getParams().setConnectionTimeout(5000);
>>>> put.setRequestEntity(entity);
>>>>
>>>> Now, I don't know, how I can put the entity in version 4? There  
>>>> are no
>>>> more
>>>> classes for RequestEntity and InputStreamRequestEntity. I didn't  
>>>> find any
>>>> code examples for Put, only for Get/Post, with this examples I  
>>>> tried to
>>>> do
>>>> the following:
>>>>
>>>> HttpClient httpClient = new DefaultHttpClient();
>>>> HttpPut put = new HttpPut(this.getArchiveURL_Put()+ "/"
>>>> +fObject.getName());
>>>> FileBody filebody = new FileBody(fObject);
>>>> MultipartEntity entity = new MultipartEntity();
>>>> entity.addPart("file", filebody);
>>>> put.setRequestEntity(entity);
>>>>
>>>>
>>>> I have removed the jar files of version 3.1 and putted the 2 jar  
>>>> files of
>>>> version 4 (also to the build-path of eclipse), but now, with the  
>>>> code
>>>> above,
>>>> I get the following error message in eclipse:
>>>> "The type org.apache.james.mime4j.message.SingleBody cannot be  
>>>> resolved.
>>>> It
>>>> is indirectly referenced from required .class files"
>>>>
>>>> Can anyone give me a hint or can tell me, if I am with the code  
>>>> above on
>>>> the
>>>> right track?
>>>>
>>>
>>> Apparently you do not have mime4j jar on the classpath. The best  
>>> way to
>>> ensure you have all dependencies is by using Maven to manage your
>>> project or by downloading the latest binary package with  
>>> dependencies:
>>>
>>> http://hc.apache.org/downloads.cgi
>>>
>>> Here's an example of multipart POST:
>>>
>>> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
>>>
>>> PUT is virtually identical to POST from the API standpoint.
>>>
>>> Oleg
>>>
>>>
>>>
>>>> Thanks in advance,
>>>> best regards and have a nice weekend!
>>>>
>>>> Mario
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
>>> For additional commands, e-mail: httpclient-users-help@...
>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/HttpClient-3.1-PutMethod--%3E-HttpClient-4-HttpPut-tp25510057p25531086.html
>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
>> For additional commands, e-mail: httpclient-users-help@...
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>

--------------------------
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-210-6378


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@...
For additional commands, e-mail: httpclient-users-help@...