Wednesday, July 2, 2008

Create a web service in asp.net

There are few step to create a new web service.

1) Create a new web service application say "TestService". In that you get "Service.asmx" file.

2) In "Service.asmx" file you got this type of content.

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}

3) When you run this web service application you got this type of



Here you see there is one method "HelloWrold" and other detail of web service.
Click on this method and you get this type of content



In this there is one button "Invoke". When you clik that button you get result
of your web service.

Hello World

4) Take a path for your web service at this time your path like this
http://localhost:3406/TestService/Service.asmx

Or

If you deploy this web service into iis then you get different pathe like this
http://youeservername/TestService/Service.asmx

2 comments:

Jegan said...

Good Article

Unknown said...

This is my first time I visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.
airport pickup w2 | heathrow to w2 | southend to w2