1. Open Visual Studio
2. Create a New Website
3. Create Web Page
4. Now Select Solution Explorer -> Add New Item -Web Service -> give Name ->Click Add.
Note: Webservice Extension is .asmx
For Creating Web Service method we need to add [WebMethod] before method.
5. Now we add the sum of two numbers method in Webservice as below.
[WebMethod]
public string addition()
{
return (10 + 20).ToString();
}
6. Save a document.
7. Now Right-click in Solution Explorer and Click Add Web Reference as shown below.
2. Create a New Website
3. Create Web Page
4. Now Select Solution Explorer -> Add New Item -Web Service -> give Name ->Click Add.
Note: Webservice Extension is .asmx
For Creating Web Service method we need to add [WebMethod] before method.
5. Now we add the sum of two numbers method in Webservice as below.
[WebMethod]
public string addition()
{
return (10 + 20).ToString();
}
6. Save a document.
7. Now Right-click in Solution Explorer and Click Add Web Reference as shown below.
8. You will see Popup as below.
9. Click Web services in this solution you will see the image as below.
10. Click the Webservice link. and Add Web Reference name which is localhost by default. now click Add Reference.
11. Write Code on Page_Load Event
protected void Page_Load(object sender, EventArgs e)
{
localhost.WebService WebRef = new localhost.WebService();
Response.Write(WebRef.addition());
}
12. Click F5.
No comments:
Post a Comment
Thanks