SilverlightShow: Using RESTful services from Silverlight Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Re: Using RESTful services from Silverlight <p>Hi Gill</p> <p>i read your article ,its simple and good for beginners.can u explain put and delete method in your article .i can't find anywhere  example like this.there is only 1 0r 2 articles explain how to  consume rest service in silverlight .so its great help for beginners like me..</p> <p>Advance Thanks</p> <p>Nixon</p> http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment8993 nixon http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Mon, 25 Feb 2013 15:30:20 GMT Re: Using RESTful services from Silverlight <p>Hi All,</p> <p>I am getting an error at line "XDocument xml = XDocument.Parse(e.Result);"</p> An exception occurred during the operation, making the result invalid.  Check InnerException for exception details. <p>Could anyone please help me? I am new to this technology and in the beginning stage.</p> <p>Thanks,</p> <p>Venkat.</p> <p><br /> </p> http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment8453 venkat.ravi231 http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Tue, 11 Sep 2012 09:30:31 GMT Re: Using RESTful services from Silverlight <p> </p> <p>Please guide me how to pass a user defined object to rest service for save or update operation--(i had tried both webclient as well as httpwebRequest ,but i am getting same error from both)</p> <p>with reference to the above code, i had written the code for passing my user defined object to rest service for save operation ,but i am getting error remote server returned an error: not found in client.UploadStringCompleted event handler.</p> <p>I am able to get my object same as above code, get part is executting successfully & i am getting my object but when i tried to pass object  in post method i am getting the error, My code snippt is as per below--</p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri; mso-spacerun: yes;">       //This is the method in rest service--</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;"><span style="mso-spacerun: yes;">        </span>[WebInvoke(UriTemplate = "CreateNewEmployee",</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;">         Method = "POST",RequestFormat=WebMessageFormat.Xml,</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;">        ResponseFormat =     WebMessageFormat.Xml)]</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;"><span style="mso-spacerun: yes;">    </span>public string PostEmployeeDetail(EmployeeDetail objEmployee)</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;">{</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;">    <span style="font-family: calibri;">//Some code is here</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri;">}</span></p>      <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri; mso-spacerun: yes;">// below is the method written in silverlight 4.0 client</span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;">   </p> <p> </p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">        </span>private void SaveEmployeeList()</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">        </span>{</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">          </span></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>WebClient client = new WebClient();</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>string updateUri = @"http://localhost:54475/Service1/CreateNewEmployee/";</p> <p><o:p _rdEditor_exists="1"> </o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>EmployeeDetail objNewEmployee = new EmployeeDetail();</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>objNewEmployee.EmployeeIdentifier = 1;</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>objNewEmployee.EmployeeName = "Arti Singh";</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>objNewEmployee.ProjectName = "SmartGrid";</p> <p><o:p _rdEditor_exists="1"> </o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(EmployeeDetail));</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>MemoryStream memoryStream = new MemoryStream();</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>dataContractSerializer.WriteObject(memoryStream, objNewEmployee);</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>string xmlData = (System.Text.Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length));</p> <p><o:p _rdEditor_exists="1"> </o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">         </span><span style="mso-spacerun: yes;">   </span>client.UploadStringCompleted += new UploadStringCompletedEventHandler (client_UploadStringCompleted);</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>client.Headers[HttpRequestHeader.ContentType] = "application/xml";</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>client.Encoding = System.Text.Encoding.UTF8;</p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span>client.UploadStringAsync(new Uri(updateUri), "POST", xmlData);</p> <p><o:p _rdEditor_exists="1"> </o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">        </span>}</p> <p><span style="mso-spacerun: yes;"></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"> </p> <p></span></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"> </p> <p> </p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="font-family: calibri; mso-spacerun: yes;">       </span><span style="mso-spacerun: yes;">    </span><span style="color: blue;">void</span> client_UploadStringCompleted(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">UploadStringCompletedEventArgs</span> e)<o:p _rdEditor_exists="1"></o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">        </span>{<span style="mso-spacerun: yes;">  </span><o:p _rdEditor_exists="1"></o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">            </span><span style="color: blue;">if</span> (e.Error == <span style="color: blue;">null</span>)<o:p _rdEditor_exists="1"></o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">                </span><span style="color: #2b91af;">MessageBox</span>.Show(e.Result);<o:p _rdEditor_exists="1"></o:p></p> <p class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-spacerun: yes;">        </span>}<o:p _rdEditor_exists="1"></o:p></p> <p class="MsoNormal" style="margin: 0in 0in 10pt;"> </p> <p class="MsoNormal" style="margin: 0in 0in 10pt;">i stucked over here & could not get any solution for it..</p> http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment8115 arti-singh http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Mon, 04 Jun 2012 13:03:18 GMT Re: Using RESTful services from Silverlight <p>oh and by the way, I am using the WCF service application as the initial template for the REST service.</p> http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment6605 suede http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Tue, 04 Oct 2011 18:00:23 GMT Re: Using RESTful services from Silverlight <p>Gill,</p> <p>I am stumbling over the same issue as Hemant. In order for you to consume the Dayweather Object in the silverlight client, you must have a reference to it somehow or perhaps duplicate the business objects on the client....which imo is not practical. Any help would be great ty.:) </p> http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment6604 suede http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Tue, 04 Oct 2011 17:57:19 GMT RE: Using RESTful services from Silverlight @<span id="ctl00_cphMiddle_ContentPlaceHolderContent_itemComments_dlstComments_ctl04_lblCommentAuthor">Hemant</span>: what do you mean that you can't get the class in the project? http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment5940 Gill Cleeren http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Wed, 20 Apr 2011 10:53:05 GMT RE: Using RESTful services from Silverlight iam not able to get DayWhether class in silverlight project. http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment5939 Hemant http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Wed, 20 Apr 2011 09:35:12 GMT RE: Using RESTful services from Silverlight It s a nice piece of code that give idea about the RESTFull services.Doing good work and thanks for this work http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment5704 Akshya Kumar Panda http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Tue, 15 Mar 2011 15:38:24 GMT RE: Using RESTful services from Silverlight This post was very helpful, thanks! http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx#comment4941 Calabonga http://www.silverlightshow.net/items/Using-RESTful-services-from-Silverlight.aspx Tue, 23 Nov 2010 07:34:59 GMT