A little bit of history always helps to get the concept better, in the case of a web service it started in 2001, when in IT industry there was a need to communicate with each other, and for businesses to communicate in digital world easily. When e-commerce was a new term in industry and jargons like B2B (Business to Business), B2C (Business to Consumer), B2G (Business to Government), C2C (Consumer to Consumer), m-commerce (Mobile Commerce) was used daily in IT world and not everyone knew how to deal with the concept.
So leaders in IT industry Microsoft, IBM, Sun, Software AG, Oracle and many others came up with web services concepts and tools to make the exchange of services, information, and products a reality.
A simple definition of web service can be a service or piece of software that is available over the net and uses standardized http and xml messaging system. For example a client invokes a web service by sending an xml message then waits for corresponding xml response. As it is in xml and it is not tied to any operating system, or programming language. This was huge at the time that became possible and still is as it brought lots of benefits like low cost of communication, standardized protocol, loosely coupled applications that can communicate with each other, atomic discovery and easy access to complex processes running CRM (customer relationship management) or ERP (enterprise resource planning) systems.
Well, I think you got the idea! Beyond the basic definition, there are concepts like WSDL, UDDI, Protocols, Service Discovery, XML-RPC, SOAP/XML that we are going to delve into these concepts to explain what they are and how they play a role in web service world.
Each web service has a public interface, WSDL (Web Services Description Language), and through simple mechanism called UDDI (Universal Description, Discover and Integreation) which a directory service, you publish and register your WSDL in there and interested parties can locate its public interface for their use via UDDI. There is a soap which is a xml based protocol to let applications exchange inforformation via http so in a very simple way UDDI says where webservices are and WSDL describes what they do and SOAP(Simple Object Access Protocol) talks to them.
The following flow diagram is self explanatory of how the process and flow of each call is in a webservice.
- Discovery – Search UDDI site(s) for the proper Web service.
- Description – A description of the selected Web service is returned to the client application as a Web Services Description Language (WSDL) file.
- Proxy creation – A local proxy to the remote service is created. The proxy converts an object’s means of method invocation into an XML message, and vice versa
- Soap Message Creation – a Soap/XML message is created and sent to the URL specified in the WSDL file.
- Listener – A Soap listener at the host site receives the call and interprets it for the Web Service.
- The Web service performs its function, and returns the result back to the client, via the listener and the proxy.
W3C defines a web service as a method of communication between two electronic device over a network. The W3C defines a web service as software system designed to support interoperable machine to machine interaction over the network. According to W3C, there are two major classes of web services exist: REST and Big Web Services, Let’s look into them and see what they are and how we can make the best use of them.
You may heard of web 2.0 technologies which brought major shift in the IT industry which we see its results almost everywhere over the net, its concepts support three main parts: Rich Internet applications, Web oriented architecture, social web. And Web API is one of the ways that helps distributing media to have RIA. And Most communications through APIs involve XML or JSON (Javascript Object Notation) payloads. And therefore REST services are greatly appreciated in Web 2.0, so REST which stands for Representational State Transfer consists of clients and servers. Clients initiate requests and servers process the requests and return appropriate response, very similar to the concept of server side development.
In REST Web services primary purpose of the service is to manipulate xml representation of web resource using a uniform set of stateless operations.
Here are the REST Web Services Characteristics:
- Client-Server: a pull-based interaction style: consuming components pull representations.
- Stateless: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server.
- Cache: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable.
- Uniform interface: all resources are accessed with a generic interface (e.g., HTTP GET, POST, PUT, DELETE).
- Named resources – the system is comprised of resources which are named using a URL.
- Interconnected resource representations – the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another.
- Layered components – intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc.
In Java world, REST support via JAX-RS API and uses annotatins to define REST relevance of classes. And Jersey is the reference implementation for this specification.
In Big Web services, the service may expose any set of operations. Big web services uses xml messages that follow the SOAP standard and have been used for so many years in EAI (Enterprise Application Integration). According to SOA, you can create your web services using two methodologies: top-down approach or bottom-up approach. In Java development, Top-down meaning you need to create the WSDL file first and in this way you have more control over the web service. Bottom-up meaning that you first need to create your Java Bean or EJB and then use the web service to create the WSDL for it. In top-down approach the WSDL is designed from a business point of view and is not driven by a service consumer or an existing application. There are several frameworks that you can use to develop your web services in Java Apache Axis, Apache CXF and Spring area among the best.
As for as the pro and cons of each method for creating web services, here is what I could come up with:
Restful Web Services | Big Web Services | |
API Flexibility | URI usage, well known and easy to use | |
Security | Use GET method over HTTP/HTTPS so cannot modify data | |
Type Handling | Soap provides stronger type handling as it has fixed set of supported data types | |
Client side Complexity | Making calls to HTTP API is significantly easier. | Making a call to Soap API. |
Testing and debugging | It is easier to test and troubleshoot HTTP API through browser | You need troubleshooting softwares like soapUI to test. |
Server-side complexity | It is more challenging to expose methods to HTTP API. | Most Programming Languages make it very easy to expose a method using SOAP. And sterilization is handled by the soap server. |
Caching | Cache response is very easy | |
Bandwidth Usage | Lightweight |
It seems that each has some advantages and disadvantages which architect and designer needs to consider and choose the appropriate web service for the each scenario and project, each has its own difficulty and ease, whatever you choose make sure it is easy to be developed and documented at the end of the road and try to visualize the whole picture from start to end. To attract more users to use your services you need to consider how easily it can be consumed by clients. Good luck!
hi its really very good data about web services.Very nice,thank you so much.