using System;using System.Collections.Generic;using System.Linq;using System.Web.Services;using System.Data.SqlClient;namespace Webservice{ [WebService(Namespace = "http://Your_URL.in/",Description="Country capital and their codes",Name="Country Details")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class WebService1 : System.Web.Services.WebService { SqlConnection con = new SqlConnection("Connection String");public class CountryDetails { public string country; public string capital; public int Code; }[WebMethod] public List country(string Country) { string sqlQuery = "select * from country where Country_Name='"+Country+"' "; con.Open(); SqlCommand com = new SqlCommand(sqlQuery, con); SqlDataReader read = com.ExecuteReader(); var stri = new List(); read.Read(); while (read.HasRows) { var s = new CountryDetails(); s.Code = Convert.ToInt32(read["Country_Code"].ToString()); s.capital = read["Capital"].ToString(); s.country = read["Country_Name"].ToString(); stri.Add(s); while (read.Read()) { var s1 = new CountryDetails(); s1.Code = Convert.ToInt32(read["Country_Code"].ToString()); s1.capital = read["Capital"].ToString(); s1.country = read["Country_Name"].ToString(); stri.Add(s1); } read.NextResult(); } return stri.ToList(); }}}