A Web Service exposes a number of methods to provide functions that can be used by one or more applications, regardless of the programming languages, operating systems, and hardware platforms used to develop them. The methods that provide such function are called Web Methods. The functions used by a Web Service can be accesses by applications using Internet standards, such as Simple Object Access Protocol (SOAP). SOAP is a protocol that uses eXtensible Markup Language (XML) to describe data and HyperText Transfer Protocol (HTTP) to transmit application data. An application that uses a Web service is called a Web service client.
Web Services bring required service into your application from the Internet in the similar way that browsers bring it to the end users. The .Net framework introduces Web Services as an integral part of the architecture, making it very easy to create and consume these services with minimal amounts of code written. In fact, if you read Microsoft's documentation, Web Services are featured as the new component architecture in the distributed age where not only Internet exposure is handled through them but also common reusable business and application services.
The .Net framework abstracts most of the internal logic that handles the remoting details of method calls over the wire and Visual Studio .Net builds support for Web Services directly into the development environment. It is as simple to call a remote method as it is to call a local method.
Web Serviceâ€™s mission is to provide a Remote Procedure Call (RPC) interface for client applications to call class methods on the server side. Actually, the handling interface on the server need not be a class, but in the case of .Net and COM before it classes are typically used as the implementing entity. The idea is that in order to create a Web Service, you create class methods with standard input and output parameters and you then mark those classes and the specific methods as exposable over the Net.
Web Services are meant to expose functionality of a server to other applications. The "client" applications in this case may be a Fat Client Windows app, a Fat Server Web application that runs a standard Web backend such as ASP, Cold Fusion, Web Connection etc., a browser based client application using script code, or even Java applet running in a browser on a Unix machine. As long as a client application has support for the Simple Object Access Protocol (SOAP) it can call the remote Web Service and return data for it, assuming the user is authorized.
Web Services Features
1. Interoperability: Enables applications developed using different languages and running on heterogeneous platforms to communicate.
2. Dynamic Integration: Enables applications to dynamically locate and integrate with one another to provide enterprise solutions
3. Industry Standards: Enables applications to communicate with each other using widely accepted industry standards, such as XML, SOAP, WSDL and UDDI.
4. Security: Enables applications to communicate with each other in a secure environment by using XML signature and XML encryption. XML signature and encryption are security mechanisms to maintain the integrity of the data that is transferred over the internet.
There are various roles involved in implementing a Web Service. These roles are responsible for performing specific functionalities during the Web service are:
o Service Provider
o Service Broker
o Service Client
A service provider is responsible for providing the software components that are published as Web services. The software components can be simple classes or complex applications written in some programming language. These software components implement the Web Service functionality. A service provider describes information of the Web Service using an interface. The interface specifies information, such as:
o Service methods that are invoked by a Client
o URL that the client needs to use to access the service.
o Network protocol required to access the Web Service.
The interface defined by the service provider is published in a centralized service registry called a service broker. The service broker allows the Web Clients to search the registry for information about published Web Services. The client and the Web service locate each other using service broker.
A service client is the potential client of the service provider's Web Service, whose information is made available by the service broker. A service client, after locating the Web Service in the service registry, invokes the services implemented by the Web Service. Locating a Web Service in the service registry and invoking its methods is known as the Web Service binding operation. A service client can be a simple Web application or another Web service accessing the published Web Services.
Benefits of Web Services
1. Easy Accessibility
Any computer that has access to the internet can easily access a Web Service. This enables a number of applications residing on different software and hardware platforms to exchange data between each other. For example, a news network such as CNN can create a Web Service, which uses a method that accepts the news categories a parameter and returns the news items belonging to the specifies category. If you want to use this web service in an application or a Web site, you can design a form to accept the news category from a user. This form can invoke the method exposed by the Web Service and display the news items returned by the method.
2. Flexibility in Structure
Depending on the requirements of a business, different types of Web Services can be created and used in an application. For example, you can create simple Web services that provide a fundamental functionality that can be used in multiple applications. You can also create Web Services to integrate the existing applications that might have been created using different software and hardware platforms. Web services also prove useful in business-to-business transactions. Business partners may have applications running on different platforms. These applications can exchange data by using Web Services.
3. Easy Integration
Using Web Services, you can easily integrate business applications developed on different software and hardware platforms resulting in low setup costs. In addition, you can integrate Web applications with applications such as spreadsheets or back-end databases to provide online information.
Elements of a Web Service
XML is used to exchange data over the internet. To enable data interchange, you require a standard data representation format that can be understood by any platform. Because XML is a plain-text format that can be understood by any type of hardware device over the Web, it is able to fulfill this requirement.
To be able to communicate with each other, a Web Service and a client application must agree upon a common protocol. SOAP is a standard communication protocol for interchanging information in a structured format in a distributed environment. The information exchanged between the client application and the Web Service ids called a message. Messages include the calls made by a client application to a Web Method and the data returned by the Web method to the client. When a client application makes a request for a web method, a SOAP packet is created. This packet contains the name of the Web method to be invoked and the parameters to be passed to the Web method in an XML format. This information is used to invoke the web method with the appropriate parameters. When the SOAP packet arrives at the Web server on which the Web Service resides, the web method name and its parameters are extracted from the SOAP packet and the appropriate Web method is invoked.
3. Web Service Description Language (WSDL)
To be able to use a Web Service, the developers of a client application need to know the methods exposed by the Web Service and the parameters to be passed to theses methods. For this reason, you need a standard method to describe the methods that are called by a Web Service. This information should be readily accessible to the Web Service clients during the design phase. WSDL is a markup language that describes a Web service.
4. Universal Description, Discovery and Integration (UDDI)
It provides a standard mechanism to register and discover a Web Service. When a web service provider wants to make a web service available to client applications, the provider describes the Web Service by using a WSDL document. Then, the provider registers the Web Service in the UDDI Directory, which contains pointers to the Web Service and the WSDL document for the Web Service.
.Net Web Services that run over HTTP can be called in 3 different ways:
HTTP GET Operation
You can pass parameters to a Web Service by calling the ASMX page with query string parameters for the method to call and the values of simple parameters to pass. Example: WebDemo.asmx/MethodName?Parm1=value
HTTP POST Operation
Works the same as GET Operation except that the parameters are passed as standard URL encoded form variables. If you use a client such as wwIPStuff you can use AddPostKey() to add each parameter in the proper parameter order. Example: WebDemo.asmx/MethodName
This is the proper way to call a Web Service in .Net and it's also the way that .Net uses internally to call Web Services.
The GET and POST operations are useful if you need to call a Web Service quickly and no SOAP client is readily available. For example, in a browser based client application it may be easier to use GET and POST instead of constructing and parsing the more complex SOAP headers that are passed back and forth in a SOAP request. But with a proper SOAP client in place SOAP provides the full flexibility of the protocol, where GET and POST operations have to stick to simple inputs and outputs. Among other things that you can do with SOAP is pass complex objects and data over the wire and for these operations to work you need to use SOAP.
Web Services' Life cycle
A Web service life cycle consists of various stages in the development and deployment process of a web service. The various stages in the life cycle of a Web Service are:
o Developing a Web Service
o Publishing a Web Service
o Locating a Web Service
o Accessing a Web Service
Developing a Web Service
This stage of Web Service involves describing the Web Service interface and implementing the business functionality of the Web Service. The web service interface contains the service methods that can be invoked by the clients. The service provider is responsible for developing a Web Service.
Publishing a Web Service
In order to make a Web Service available to service clients on the web, the web service is published in a service registry. A published web service stores the complete information regarding how a service client can access the Web Service.
Locating a Web Service
The client searches for a specific Web Service in the service registry. When the client locates the Web Service, it obtains the information from the registry that is required to access the Web Service.
Accessing a Web Service
After locating the Web Service, the client connects to the Web Service directly to access its services. The client accesses the Web service through the URLs provided by the service provider in the registry the XML-based protocol, SOAP.
What is SOAP?
The basic Web services platform is XML plus HTTP.
- SOAP stands for Simple Object Access Protocol
- SOAP is a communication protocol
- SOAP is for communication between applications
- SOAP is a format for sending messages
- SOAP is designed to communicate via Internet
- SOAP is platform independent
- SOAP is language independent
- SOAP is based on XML
- SOAP is simple and extensible
- SOAP allows you to get around firewalls
- SOAP will be developed as a W3C standard
What is WSDL?
WSDL is an XML-based language for describing Web services and how to access them.
- WSDL stands for Web Services Description Language
- WSDL is written in XML
- WSDL is an XML document
- WSDL is used to describe Web services
- WSDL is also used to locate Web services
- WSDL is not yet a W3C standard
What is UDDI?
UDDI is a directory service where businesses can register and search for Web services.
- UDDI stands for Universal Description, Discovery and Integration
- UDDI is a directory for storing information about web services
- UDDI is a directory of web service interfaces described by WSDL
- UDDI communicates via SOAP
- UDDI is built into the Microsoft .NET platform