• What are the Web Services and how to create a Web Service in ASP.NET?

    by  • May 25, 2013 • Microsoft .NET Web Services, Microsoft ASP.NET • 1 Comment

    What is a Web Service?

    A Web Service is a software program that uses XML to exchange information with other software via common internet protocols. Web Service is way to interact with other object via internet. It is an application that is designed to interact with other applications. Web services allow servers to expose its functionality and clients can use this functionality according to their requirements.

    In plain words we can say that it is a method of communication between two devices over the internet. A web service is function that can be accessed by other programs via internet. So the target of web services is not humans rather other programs. Web Services are protocol, platform and language independent and it is based on XML so all the communication is in XML.

    Web Services Technologies

    Web services use following technologies.

    XML (Extensible Markup Language)

    It is a markup language that provides standard rules to encode data to carry via internet. It allows users to define their own tags rather than predefined tags.

    SOAP (Simple Object Access Protocol)

    It is based on XML and it actually the communication protocol. It provides communication mechanism between web services and applications via internet.

    WSDL (Web Services Description Language)

    It is also based on XML and it is used to describe and locate Web Services.

    UDDI (Universal Description, Discovery and Integration)

    It is actually the directory for storing information about web services and web services interfaces.


    • Open Visual Studio 2010 and Select New Website form File > New
    • Now Select Add New Item from Website and select Web Service

    create a Web Service 1

    • You will see following window on your screen.

    create a Web Service 2

    • A WebMethod HelloWorld() is already there but you can write your own web methods as I have written Multiply() web method. This method takes two integer parameters, multiplies them and returns integer value.

    Two important things to note here are System.Web.Services namespace and [WebMethod] attribute. You must have to use System.Web.Services namespace and specify [WebMethod] attribute top of the every method you want to expose as part of the web service. You must also need to declare these methods “public”.

    • Press F5 and you will see following in your browser.

    create a Web Service 3

    • You can test the web service by clicking on “Multiply”.
    • Now provide two values and click on “Invoke”.

    create a Web Service 4

    • You will see the result like this.

    create a Web Service 6

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of GetCodeSnippet.com


    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    One Response to What are the Web Services and how to create a Web Service in ASP.NET?

    1. John
      May 25, 2013 at 7:09 pm

      Thanks for sharing detailed information about web services. This is quite helpful.

    Leave a Reply