<

Asp.Net Web Service for Different Platforms

Published on
8,510 Points
2,510 Views
Last Modified:
Approved
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
0 Comments

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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…
Please check the video also in regards to recovery of deleted emails from office 365 admin center and through the MFCMAPI tool. I have mentioned each and every step with the proper steps that need to be taken care of.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month