Regarding generating .xml filehttp://forums.asp.net/t/1798286.aspx/1?Regarding+generating+xml+fileTue, 01 May 2012 17:46:01 -040017982864957321http://forums.asp.net/p/1798286/4957321.aspx/1?Regarding+generating+xml+fileRegarding generating .xml file <p>Hi All,</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I created a web service and it is working fine my local machine. Now we want to implement it on our project. What we require is:</p> <p>1] My Web Service reads the Employee Number and it returns his name. Once i publish it, this web service should generate .xml file. So that we can access this on other platform(such as : Andriod)</p> <p>I don't know how to do this. Please guide me for this.</p> <p></p> <p>Thanks.</p> 2012-04-30T03:23:49-04:004957406http://forums.asp.net/p/1798286/4957406.aspx/1?Re+Regarding+generating+xml+fileRe: Regarding generating .xml file <p>As per my opinion use Type data set is best option because after fill data set you can generate xml file very easily add new item and select type dataset (xsd) file</p> <p>Here is benefit of Type dataset</p> <ol> <li>You can fill as many table as you want multi table </li><li>Easily modified it </li><li>Easily generate xml file with schema </li></ol> <p>Code for generate xml</p> <pre class="prettyprint">Packing objPacking = new Packing(); string filename = @&quot;D:\PackingSampleData.xsd&quot;; objPacking.WriteXml(filename, XmlWriteMode.WriteSchema);</pre> <p></p> <p></p> 2012-04-30T05:17:16-04:004959140http://forums.asp.net/p/1798286/4959140.aspx/1?Re+Regarding+generating+xml+fileRe: Regarding generating .xml file <p>Hi,</p> <p>If you can use WCF to build the webservice, then I'd strongly recommend you create it as a WCF REST service. The REST programming model can help you define service operations that can be called through simple and standard HTTP GET/POST request.</p> <p>#An Introduction To RESTful Services With WCF <br> <a href="http://msdn.microsoft.com/en-us/magazine/dd315413.aspx">http://msdn.microsoft.com/en-us/magazine/dd315413.aspx</a></p> <p>#WCF Web HTTP Programming Model Overview <br> <a href="http://msdn.microsoft.com/en-us/library/bb412172.aspx">http://msdn.microsoft.com/en-us/library/bb412172.aspx</a></p> <p>#WCF REST Service Template 40(CS) <br> <a href="http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd">http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd</a></p> <p>For your case, you want to expose some Xml format data to client (either .NET or java/android), you can define a service operation which return a XElement object(which contains the XML data you want to return). e.g.</p> <p>&nbsp;</p> <pre class="prettyprint">[ServiceContract] public interface ISimpleRESTService { ...... [WebGet] [OperationContract] XElement GetXmlData(); } public class SimpleRESTService : ISimpleRESTService { ...... public XElement GetXmlData() { var elm = XElement.Parse( @&quot;&lt;dataRoot&gt; &lt;items&gt; &lt;item id='1'&gt;item 1&lt;/item&gt; &lt;item id='2'&gt;item 2&lt;/item&gt; &lt;item id='3'&gt;item 3&lt;/item&gt; &lt;/items&gt; &lt;/dataRoot&gt;&quot;); return elm; } }</pre> <p><br> then, you can directly invoke the operation in web browser or use strong-typed client(as long as it support sending HTTP get/post requests).</p> <p>Here are some web articles on consuming REST service from windows phone 7 client and android client:</p> <p>#Consuming WCF 4.0 REST Service in Windows Phone 7 <br> <a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=501">http://www.dotnetcurry.com/ShowArticle.aspx?ID=501</a></p> <p>#Calling a REST web service from Android <br> <a href="http://timewasted.net/?p=127">http://timewasted.net/?p=127</a></p> 2012-05-01T03:11:18-04:004959789http://forums.asp.net/p/1798286/4959789.aspx/1?Re+Regarding+generating+xml+fileRe: Regarding generating .xml file <p>Hi Bhavik,</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Your code helped me to create .xml file on the server and i got every records in it.</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Now my next question is, if I pass Roll Number then it returns me Student Name and for that I wrote a web service. But can i generate .xml file for the partucular student which generated? When we add reference of the web service during that it displays the student name in .xml format. something like that...</p> <p></p> <p>thanks</p> <p></p> <p></p> <p></p> 2012-05-01T12:00:27-04:004960372http://forums.asp.net/p/1798286/4960372.aspx/1?Re+Regarding+generating+xml+fileRe: Regarding generating .xml file <p>I just change my select * query and execute the query</p> <p></p> <p>many thanks to all</p> 2012-05-01T17:46:01-04:00