What is Web Service?
Web Service is an application that is designed to interact directly with other applications (on the same or different platforms) over the internet.
Web Service is language independent and they communicate by using standard web protocols and data formats, such as
- HTTP (HTTP is the widely used protocol to transfer files over internet)
- XML
- SOAP (SOAP message are in the form of XML Format)
Advantages of Web Service
Web Service messages are formatted as XML, a standard way for communication between two systems which are on the same or different platforms. And this message is sent via HTTP so that they can reach to any machine on the internet without being blocked by the Firewall.
- Web Services are interoperable so that applications built on different platforms can consume it.
- Web services may extend or add, remove their methods without affecting the client as long as they still provide the same signature of methods.
- When a client requests the web service, the connection is opened and after getting a response, the connection is closed. There is no permanent connection between the two. That is why multiple clients can interact with the web services simultaneously without affecting performance.
Web Services using .NET Framework
There are three aspects of web service development (We will cover in next chapters) -
- Creating Web Service
- Creating a Proxy (Proxy is the channel between the client and service for communication. It is built on Client side and is responsible for communicating with the Web service)
- Consuming Web Service
Other Notes and Tips
- “System.Web.Services.WebService” is used for asp.net session state, application state, etc.
- It is not mandatory for a web service to inherit from Services.WebServicebase class. However, if the web service has to use ASP.NET session or application state objects, then inheriting from System.Web.Services.WebServicebase class will provide direct access to these asp.net objects.
- The extension for asp.net web service is “.asmx”, that is why it is also called asmx web services.
- [WebMethod] attribute above the function in the web service is used if you want to expose the method/function to the outer world. And the method access modifier should always be “Public”.