Wednesday, July 2, 2008

How to use web service in asp.net - Part -> 1

There are few step to add a new web service to asp.net

-> First create a new web application.

-> Then go to your project and right click and see there is one option "Add Web References".



-> Then you got this type of pop up window on your screen and in this you enter your web
service url and click "go" button near the url text box. You give one name to your web service
say "Test" above the "Add Reference" button. then click this button and you see they create a
new folder in the "App_WebReferences" and in that floder they create your "Test" floder and
put your web service in this folder.




-> Now in you sample.aspx.cs page add reference of that web service this way.
using Test;
-> Now in pagload or any event you want to used this web service in your page this way. I write
in page load event. To print "Hello wrold".

protected void Page_Load(object sender, EventArgs e)
{
Service objservice = new Service();
Response.Write(objservice.HelloWorld());
}

-> Run This sample and you got this result.

No comments: