开发者

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,

  1. I want to post a new customer entry into mysql database,
  2. I am not using any HTML form,
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜