Last post Mar 02, 2013 05:37 AM by Haixia Xie - MSFT
Feb 18, 2013 03:07 AM|Hem Singh|LINK
I have to write web services in .net for other platforms like android(java), & IOS. I have created one and also consumed in .net. It is easy to write and consume web services in .net with VS. I have returned data through DataSet and accessed it in a DataSet
from remote server easily.
But I want to confirm one thing. what is the best way to return data from database tables so others like java developers can access it easily. One option I am thinking to use is: a Class as return type of Webmethods and return data through this Class members/properties.
But if there are other good options to return data in xml format please suggest me.
Feb 19, 2013 04:50 AM|Haixia Xie - MSFT|LINK
You can return XmlDocument instead of DataSet from web method, you can use code similar below to display Xml on the client.
string xmlStr = null;
XmlDocument xmlDoc = default(XmlDocument);
xmlStr = myDataSet.getxml;
Refer a blog #Web Services, a simple approach
Hope it helps.
Feb 19, 2013 08:59 AM|Hem Singh|LINK
@Haixia thanks for the reply but XmlDocument is obsolete. Currently I am returning data as an array of a class. There is another option XDocument of LINQ to XML. But I am not familiar with this yet.
Feb 21, 2013 12:59 AM|Haixia Xie - MSFT|LINK
thanks for the reply but XmlDocument is obsolete. Currently I am returning data as an array of a class. There is another option XDocument of LINQ to XML. But I am not familiar with this yet.
If you do not want to use XDocument, you can consider create a Restful service and return XML data, set the ResponseFormat to WebMessageFormat.Xml
Refer a sample from #Create RESTful WCF Service API: Step By Step Guide
Feb 25, 2013 01:12 AM|Hem Singh|LINK
@Haixia thanks for the reply. I am not denying the use of XDocument but XMLDocument. XDocument is good. It is a part of LINQ to XML. But I have not used it.
As you have suggested WCF someone has suggested Web API. Which one is good: wcf or web api for web services?.
Mar 02, 2013 05:37 AM|Haixia Xie - MSFT|LINK
The new ASP.NET Web API is a continuation of the previous
WCF Web API projection, WCF was originally created to enable SOAP-based services.
A comparision between #WCF and ASP.NET Web API