Create a hello world web service
<%@ WebService Language="C#" Class="HelloService"%> using System; using System.Web.Services; using System.Xml.Serialization; [WebService( Namespace="http://localhost/HelloServices/")] public class HelloService : WebService { [WebMethod] public string SayHello() { return "Hello World!"; } }
Create an aspx web page to consume HelloService
- wsdl http://localhost/HelloServices/HelloService.asmx
- csc /t:library HelloService.cs
<%@ Page Language="C#" %> <script runat=server> void runService_Click( Object sender, EventArgs e) { HelloService hs = new HelloService(); Label1.Text = hs.SayHello(); } </script> <html> <body> <form id="Form1" runat=server> <asp:Label id="Label1" runat="server">Label</asp:Label> <br /> <asp:Button id="runService" onclick="runService_Click" runat="server" Text="Hello"/> </form> </body> </html>