User Id:
Password:
Forgot User ID or Password?
     
 
Facebook Twitter Linked In Stumble Upon Digg In
Articles
Database(11)
Desktop Development(3)
Development Lifecycle(2)
Dot Net Nuke(1)
Enterprise Systems(1)
Frameworks & Libraries(0)
General Programming(25)
General Reading(6)
Graphics / Design(10)
Languages(2)
Mentor Resources(0)
Mobile Development(3)
Multimedia(0)
Research Papers(1)
Social Media(1)
Software Engineering(3)
Third Party Products(0)
Web Development(11)
Add a Article
 
Articles

How to write a simple Web Service in .Net

Write a simple .asmx Web service

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. Create a new Active Server Pages (ASP) .NET Web service project. Name the Web service MathService and point the location to an appropriate Web server that is running ASP.NET if necessary.
  3. Change the name of the Solution file to MathService for consistency.
  4. Change the name of the default Web service that is created from Service1.asmx to MathService.asmx.
  5. Click Click here to switch to code view in the designer environment to switch to code view.

    Change the name of the class from Public Class Service1 to Public Class MathService.
  6. Define methods that encapsulate the functionality of your service. Each method that will be exposed from the service must be flagged with a WebMethod attribute in front of it. Without this attribute, the method will not be exposed from the service.

    NOTE: Not every method needs to have the WebMethod attribute. It is useful to hide some implementation details called by public Web service methods or for the case in which the WebService class is also used in local applications. A local application can use any public class, but only WebMethod methods will be remotely accessible as Web services.

    Add the following method to the MathServices class that you just created:

    Public Function Add(a As Integer, b As Integer) As Integer Return(a + b) End Function Public Function Subtract(A As System.Single, B As System.Single) As System.Single Return A - B End Function Public Function Multiply(A As System.Single, B As System.Single) As System.Single Return A * B End Function Public Function Divide(A As System.Single, B As System.Single) As System.Single If B = 0 Return -1 End If Return Convert.ToSingle(A / B) End Function

  7. Click Build on the Build menu to build the Web service.
  8. Browse to the MathService.asmx Web service page to test the Web service. If you set the local computer to host the page, the URL is http://localhost/MathService/MathService.asmx.

    The ASP.NET runtime returns a Web Service Help Page that describes the Web service. This page also enables you to test different Web service methods.

Average: 5.0000, Total Ratings: 1

 



FAQ Messages  newPost a Message 
There is no message currently

 
Last Updated November 19, 2018 | Advertise | Privacy Policy
Copyright © QAU Programmers, 1999-2018 All Rights Reserved. Terms of Use