Hello,

Actually I am using the following code example to request a POST method on my 
Restful service:
-----------------------------------------------------------------------------------------------------------------------------------------------
        System.out.println("Sent HTTP POST request to add customer");
        inputFile = client.getClass().getResource("add_customer.xml").getFile();
        resolver = new URIResolver(inputFile);
        input = new File(resolver.getURI());
        PostMethod post = new 
PostMethod("http://localhost:8080/CustomerRestfullTest/jaxrs/customerservice/customers";);
        post.addRequestHeader("Accept" , "text/xml");
        entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");
        post.setRequestEntity(entity);
        httpclient = new HttpClient();

        try {
            int result = httpclient.executeMethod(post);
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(post.getResponseBodyAsString());
        } finally {
            // Release current connection to the connection pool once you are
            // done
            post.releaseConnection();
        }
-----------------------------------------------------------------------------------
My request is thus build by using an XML data file "add-customer.xml" where I 
can put for example:
<Customer>
  <id>1</id>
  <name>toto</name>
</Student> 

I would like to do a similar request but instead of using the xml file I prefer 
to have a java class, 
"Customer", and to do then something like that:
Customer c = new Customer(1, "toto");
PostMethod post = new 
PostMethod("http://localhost:8080/CustomerRestfullTest/jaxrs/customerservice/customers";);
post.setRequest(c);

Is there a way to do that in cxf?

Regards,

Diana

Reply via email to