This mini tutorial, i will show how to create a web service using VS2008. At the end of the tutorial, a simple calculator will be created. User just need to key in the value of Principle, Interest and Rate, Interest will be returned.
1. From VS 2008, choose “File” menu, select “New-Web Site”. Select “ASP.NET Web Service”.
2. On the "New WebSite" Dialog Box, choose a Location as “File System”. Click "Browse" button to specify the folder where your solution will be stored.
3. Select C# as the Language. Click "Ok" when done.
4. Once ready, on the left pane (Solution Explorer), find and rename “Service.cs” to “FinancialWebSvc.cs” and “Service.asmx” to “FinancialWebSvc.asmx”.
5. Next open the FinancialWebSvc.asmx, change
CodeBehind= “~/App_code/Service.cs” to
CodeBehind= “~/App_code/FinancialWebSvc.cs”
Class= “Service” to
Class= “FinancialWebSvc.”
6. Select “Build” menu and click on “build Solution” menu under it.
Right click on the FinancialWebS project on the left pane.
Add the following code to your FinancialWebSvc.cs file
[WebMethod(Description = "Return interest")]
public int ComputeInterest(int P, int time, int rate)
{
int interest;
interest = (P * time * rate) / 100;
return interest;
}
5. From the "Build" menu, select "Build Solution".
7. Now you are ready to test out your newly created web service. From "Debug" menu, click on "Start Debugging"
Monday
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment