Answered by:
which is the best way to return data in xml format with web services

Question
-
User-935979976 posted
Hi,
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.
Monday, February 18, 2013 3:07 AM
Answers
-
User-1000095884 posted
Hem Singh
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.Hi,
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
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 21, 2013 12:59 AM -
User-1000095884 posted
Hi,
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
http://msdn.microsoft.com/en-us/library/jj823172.aspx
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 2, 2013 5:37 AM
All replies
-
User-1000095884 posted
Hi,
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; xmlDoc.LoadXml(xmlStr);
Refer a blog #Web Services, a simple approach
http://www.codeproject.com/KB/XML/webservicessimple.aspx
Hope it helps.
Best Regards.
Tuesday, February 19, 2013 4:50 AM -
User-935979976 posted
@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.
Tuesday, February 19, 2013 8:59 AM -
User-1000095884 posted
Hem Singh
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.Hi,
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
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 21, 2013 12:59 AM -
User-935979976 posted
@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?.
Monday, February 25, 2013 1:12 AM -
User-1000095884 posted
Hi,
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
http://msdn.microsoft.com/en-us/library/jj823172.aspx
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 2, 2013 5:37 AM