Advantages And Uses Of Web Services In C#

Today, I am going to explain, what are web service in .NET with advantages and uses.. I will also explain how web services came in picture and before web services which technology worked.

What is web service

Web Service is an application or we can say a standard way for interacting directly with other applications over the internet. It is a way to develop interoperable application over the internet.

Web Service can locate on same computer within same network or different computer with different network. Web service is protocol independent, language independent and platform independent. Web services support standard protocol and data format like HTTP, XML, and SOAP.

web service

How web services came in picture

Before web service there were two more technologies in picture,

COM

COM is known as Component Object Model. It allows interacting two objects on the same computer or machine but application can be different. We cannot use different application located on different computer using COM. It was the limitation of COM.

DCOM

To remove limitation of COM, a new technology introduced known as DCOM. DCOM is short form of Distributed Component Object Model. Using DCOM we can access two different application or object on different computer but both applications must be on same network. This was the limitation of DCOM.

Web Service

To remove limitation of DCOM new interoperable technology came in picture known as Web service that allow us to interact with other object or application which is located on different network.

  1. using System;  
  2. using System.Collections;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Linq;  
  6.   
  7. using System.Web;  
  8. using System.Web.Services;  
  9. using System.Web.Services.Protocols;  
  10.   
  11. using System.Xml.Linq;  
  12.   
  13. namespace StockService  
  14. {  
  15.     // <summary>  
  16.     // Summary description for Service1  
  17.     // <summary>  
  18.   
  19.     [WebService(Namespace = "http://tempuri.org/")]  
  20.     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
  21.     [ToolboxItem(false)]  
  22.   
  23.     // To allow this Web Service to be called from script,   
  24.     // using ASP.NET AJAX, uncomment the following line.   
  25.     // [System.Web.Script.Services.ScriptService]  
  26.   
  27.     public class Service1 : System.Web.Services.WebService  
  28.     {  
  29.         [WebMethod]  
  30.   
  31.         public string HelloWorld()  
  32.         {  
  33.             return "Hello World";  
  34.         }  
  35.     }  
  36. }  
Advantage of web services

Web services use XML format message to interact with other system. Xml format is a standard way to communicate between two incompatible systems. Web service sent message over HTTP protocol. So, message reaches to any system over internet without being blocked by firewall.

What is WSDL

WSDL means Web Services Description Language. Web services description language tell to client what types of message it accept and what will be returned as an output. WSDL contain every detail of web services like what is communication protocol method name, data type used.

Advantage of web service

Reference

If you want to know more please click here.

Thanks for reading this article, hope you enjoyed it.

 

Up Next
    Ebook Download
    View all
    Learn
    View all