using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Data.Sql; using System.Data.SqlClient; /// /// Summary description for teenus1 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class teenus1 : System.Web.Services.WebService { public teenus1 () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World!"; } [WebMethod] public string Tervita(string eesnimi) { return "Tere, " + eesnimi; } [WebMethod] public string ToitudeNimed() { SqlConnection cn = new SqlConnection( "Data Source=localhost;Initial Catalog=xml1;Integrated Security=true"); SqlCommand cm = new SqlCommand("SELECT id, nimetus FROM toiduained " + "FOR XML RAW('aine'), ROOT('ained'), TYPE", cn); cn.Open(); string vastus = cm.ExecuteScalar().ToString(); return vastus; } }