Can you give me an example with plain text request??

Thank you


Arul Dhesiaseelan wrote:
> 
> It depends on what your resource can consume. You can post plain text or 
> json or xml request too.
> 
> The below sample allows you to post an XML request to your resource.
> 
> @Path("/customers")
> public class Customers {
>   @POST
>   @Path("add")
>   @ConsumeMime(MediaType.APPLICATION_XML)
>   public Response addCusomter(Customer customer) {
>       //process the customer pojo in memory or db
>   }
> }
> 
> 
> You can send in a customer XML in the HTTPClient post operation as
>     File input = new File("customer.xml");
>     PostMethod post = new
> PostMethod("http://localhost:8080/customers/add";);
>     post.addRequestHeader("Accept" , "application/xml");
>     RequestEntity entity = new FileRequestEntity(input,
> "application/xml");
>     post.setRequestEntity(entity);
>    
>     httpclient.executeMethod(post);
> 
> HTH.
> 
> -Arul
> 
> deniak wrote:
>> Hi all
>>
>> I just start with CXF and i have a little problem with the post method.
>> Here's my code:
>>
>> - myClass.java
>> @Path("test")
>> public class myClass{
>>      @POST
>>      @Path("/newtest")
>>      public String myMethod(String myParam){
>>               return myParam;
>>         }
>> }
>>  
>>
>> To test my webservice, i execute this code:
>>
>>  
>> public static void main(String args[]) {
>>      PostMethod post = new
>> PostMethod("http://localhost:8080/test/newtest";);
>>      HttpClient httpclient = new HttpClient();
>>      try {
>>             int result = httpclient.executeMethod(post);
>>      }finally {
>>             post.releaseConnection();
>>      }
>> }
>>  
>>
>> My question is how do I specify the parameter "myParam" in the main
>> method?
>>
>> Thanks for your help
>>   
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CXF-Rest-Post-Method-tp18144858p18148713.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to