Sponsored Ad

Tuesday, September 29, 2009

C# Web Services

This tutorial shows how to create and use Web Services in C#. We begin with an a general overview of .NET Web services concepts and technologies used to implement Web services. Next, we present a step-by-step walkthrough of building and deploying a HugeInteger Web service that performs calculations with integers up to 100 digits long. We then build a Window application that consumes the Web service. This tutorial is intended for students who are already familiar with C# and for C# developers.

Following is our first Web Service; it exposes two methods (Add and SayHello) as Web Services to be used by applications. This is a standard template for a Web Service. .NET Web Services use the .asmx extension.

 

using System;
using System.Web.Services;
using System.Xml.Serialization;

[WebService(Namespace= href="http://localhost/MyWebServices/"http://localhost/MyWebServices/)]
public class FirstService : WebService
{
     [WebMethod]
     public int Add(int a, int b)
     {
         return a + b;
     }

     [WebMethod]
     public String SayHello()
     {
         return "Hello World";
     }
}

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers