2

I retrieve a XML file from my rest service like the following:

   xmlhttp.open( "GET",
                 "http://localhost:8080/manager/rest/beanRepresentation/", 
                 false );
   xmlhttp.send();
   xmlDoc=xmlhttp.responseXML; 

Now that the XML is stored in xmlDoc, I will change some fields in this xmlDoc. Say I make a change through my webpage, and change the the following:

xmlDoc.getElementsByTagName("beanRepresentation")[i]
      .getElementsByTagName("personName")[0]
      .childNodes[0]
      .nodeValue = "John";

Now that this change is made. I want to PUT this newly changed xmlDoc back to my rest service and update it, so next time I load my page, the name will be John.

How do I do this? Is this the right way?

   xmlhttp.open("PUT",
                "http://localhost:8080/manager/rest/beanRepresentation/",
                false);
   xmlhttp.send(xmlDoc);

the rest service is able to handle "PUT" by the way.

MackieeE
  • 11,751
  • 4
  • 39
  • 56
PhoonOne
  • 2,678
  • 12
  • 48
  • 76
  • Related: http://stackoverflow.com/questions/630453/put-vs-post-in-rest – crush Jan 29 '14 at 16:23
  • It seems like you could use `PUT` here, if I'm interpreting what you are doing correctly. `PUT` should be used when you are replacing the resource at the specified URL. – crush Jan 29 '14 at 16:28
  • Dude have u got answer ?. – Naren Jan 31 '14 at 11:06

0 Answers0