<

[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x

Asp.Net Web Service for Different Platforms

Published on
8,375 Points
2,375 Views
Last Modified:
When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc.

Solution :
Return a XML Document instead  of Dataset .

Coding  like :
[WebMethod]
public XmlDocument MydataProvided()
{
   Dataset DS = new DataSet ()
   // here you should write some login to fill  the dataset
   return GetDSXml(DS);
}

public XmlDocument GetDSXml(Dataset  ds)
{
   System.IO.StringWriter sw = new System.IO.StringWriter();
   ds.WriteXml(sw);
   sw.Close();
   XmlDocument xd = new XmlDocument
   xd.LoadXml(sw.ToString());
   return xd;
}

Open in new window


Also, by adding the following method a DataTable can be returned easily.

public XmlDocument GetDtXml(DataTable  dt)
{
   System.IO.StringWriter sw = new System.IO.StringWriter();
   dt.WriteXml(sw);
   sw.Close();
   XmlDocument xd = new XmlDocument
   xd.LoadXml(sw.ToString());
   return xd;
}

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
0 Comments

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

Join & Write a Comment

The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month