Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I call delete/put method to rest service from silverlight
    text
    copied!<p>I get many articles regarding post and get method in rest service but I didn't get any good one for put/delete. I created one rest service and tried to call four operation. Get and post working but put/delete not. I will provide my code here;</p> <p>in silverlight put and post method calling rest service</p> <pre><code> const string uridel = "http://localhost:50211/CustomerService.svc/deletecustomer/1"; const string uriput = "http://localhost:50211/CustomerService.svc/modifycustomer/1"; client.DownloadStringCompleted += (s, ev) =&gt;//delete method { XDocument xml = XDocument.Parse(ev.Result); var Customer = from results in xml.Descendants ("CustomerResponse") select new CustomerResponse { CustomerId = Int32.Parse(results.Descendants ("CustomerId").First().Value), }; int id = Customer.Select(w =&gt; w.CustomerId).FirstOrDefault(); MessageBox.Show("result is :" + id); }; client.DownloadStringAsync(new Uri(uridel), "DELETE"); CustomerResponse cusres = new CustomerResponse();//put method cusres.CustomerName = textBox1.Text; cusres.CustomerPh = textBox2.Text; DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(CustomerResponse)); MemoryStream memoryStream = new MemoryStream(); dataContractSerializer.WriteObject(memoryStream, cusres); string xmlData = Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length); client.UploadStringCompleted += (s, ev) =&gt; { XDocument xml = XDocument.Parse(ev.Result); var Customer = from results in xml.Descendants("CustomerResponse") select new CustomerResponse { CustomerId = Int32.Parse(results.Descendants ("CustomerId").First().Value), }; int id = Customer.Select(w =&gt; w.CustomerId).FirstOrDefault(); MessageBox.Show("result is :" + id); textBox1.Text = ""; textBox2.Text = ""; }; client.Headers[HttpRequestHeader.ContentType] = "application/xml"; client.UploadStringAsync(new Uri(uriput), "PUT", xmlData); </code></pre> <p>in wcf service</p> <pre><code> [OperationContract] [WebInvoke(Method = "DELETE", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "deletecustomer/{id}")] CustomerResponse DeleteCustomer(string id); [OperationContract] [WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "modifycustomer/{id}")] CustomerResponse ModifyCustomer(string id,CustomerResponse cusres); </code></pre> <p>For delete I got one exception that server not found and for the put method I got on error like specified method is not support in this request. Can anyone suggest where the error is..or suggest good articles that can use put and delete method consume in silverlight?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload