Restlet framework with post method
I am using restlet 1.0, and i am trying to post a new entry into my Mysql database. I am not using any HTML form, i want to do all operation on MY rest client. The problem i am facing is,
- I want to post a new customer entry into mysql database,
- I am not using any HTML form,
- I am trying to achieve and create XML in Rest Client, and trying to send XML.
My REST url for post method is http://localhost:8182/api/service/customers/
How to append the new customer information and how to get XML.
Please help.
开发者_如何学运维Thanks
Karunjay Anand
If you rest client is a java based client, you can use the URLConnection (HTTPUrlConnection) to post data to the server.
URL url = new URL("http://localhost:8182/api/service/customers/");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(xml); // write your xml
wr.flush();
wr.close();
Alternatively you can also use the HTTPClient library to do posts.
精彩评论