Web Service has been around since year 2000. Today I still see people serialize XML to pass data in Web Service in .NET platform. Do not do web services to return data by serializing XML. You can use Dataset to pass the data if your application is only call in .NET platform. It is far simpler than constructing your own XML.
The sample in codeproject.com could be good “How To Use ASP.NET Web Service with FlexiGrid” but it is not a necessary for a .NET platform to write XML serialization for web service in this way. If your application will only use .NET platform you can do it in the way below.
In Web Service end. You can create a WebMethod.
public class WebService1 : System.Web.Services.WebService
static DataSet GetConnection()
string connectionString = ConfigurationManager.ConnectionStrings[“oms”].ConnectionString;
//Create a SqlConnection to the Northwind database.
SqlConnection connection =
//Create a SqlDataAdapter for the Suppliers table.
SqlDataAdapter adapter = new SqlDataAdapter();
// A table mapping names the DataTable.
// Open the connection.
//Console.WriteLine(“The SqlConnection is open.”);
// Create a SqlCommand to retrieve Suppliers data.
SqlCommand command = new SqlCommand(
“SELECT * FROM dbo.Customer;”,
command.CommandType = CommandType.Text;
// Set the SqlDataAdapter’s SelectCommand.
adapter.SelectCommand = command;
// Fill the DataSet.
DataSet dataSet = new DataSet(“Customer”);
public DataSet GetAllProducts()
In the WebForm UI side with one button and a gridview webcontrol. You can code the button as follow.
protected void GetWSProducts()
WSProducts.WebService1 proxy = new WSProducts.WebService1();
DataSet ds = new DataSet();
ds = proxy.GetAllProducts();
GridView1.DataSource = ds;
GridView1.DataMember = “Customer”;
protected void Button1_Click(object sender, EventArgs e)