tags:

views:

48

answers:

1

Hi,

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

A: 

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.

naikus
@ naikus, since i want to post new customer entry, so need to read that information from database and storing in a value object, will you please tell me, how can i render that information into XML?and how to store that object i a header, so i can post the data.Thanks