In this article, We will see what is web Service? How is web Service useful? Why you need webServices ? What are the Types of WebService? and much more.
What is Web Service ?
A service-oriented architecture is essentially a collection of services. Web service is a way of communication, Web Service allows interoperability between different applications on different platforms. For example, a java based application on Windows can communicate with a .Net based one on Linux. The communication can be done through a set of XML messages over HTTP protocol or SOAP Protocol.
Web services are browsers and operating system independent, which means it can run on any browser without the need of making any changes.
What is need of Web Services?
Web Services is very useful software services. Let’s see the pointed and descriptive explanation of web services.
1. Code Reusability: Suppose you are developing a Healthcare software on java and you have an old .net software which manages patients insurance. So rather than develop a new software for insurance part,you can use old software and for other business requirements, you can develop your code in java. Using this way you can reuse the old application code and communicate with the old application using WebServices.
2. Interoperability: It’s the most important benefit of Web Services. Web Services typically work outside of private networks, offering developers a non-proprietary route to their solutions.
Web Services also let developers use their preferred programming languages. In addition, thanks to the use of standards-based communications methods, Web Services are virtually platform-independent.
3. Loosely Coupled: Webservices are independent of each other. Each service exists independently of the other services that make up the application. Individual pieces of the application to be modified without impacting unrelated areas.
Three specifications for Web Services are illustrated in this section: SOAP, REST, and JSON.
1. SOAP : SOAP stands for Simple Object Access Protocol. SOAP is a protocol specification for exchanging structured information in the implementation of Web services in computer networks. It relies on XML as its message format. SOAP was originally part of the specification that included the Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI). It is used now without WSDL and UDDI. Instead of the discovery process described in the History of the Web Services Specification section below, SOAP messages are hard-coded or generated without the use of a repository.
2. REST : Representation State Transfer (REST) appeals to developers because it has a simpler style that makes it easier to use than SOAP. The use of REST is often preferred over the more heavyweight SOAP (Simple Object Access Protocol) style because REST does not leverage as much bandwidth, which makes it a better fit for use over the Internet. The SOAP approach requires writing or using a provided server program (to serve data) and a client program (to request data).
What is WSDL ?
WSDL stands for Web Service Description Language. It is an XML file that describes the technical details of how to implement a web service, more specifically the URI, port, method names, arguments, and data types. Since WSDL is XML, it is both human-readable and machine-consumable, which aids in the ability to call and bind to services dynamically.
Elements of WSDL :
It is the root element of a WSDL file. It usually contains a set of namespace declarations which are used throughout the WSDL file.
The WSDL types element describes the data types used by your web service. Data types are usually specified by XML schema. It can be described in any language as long as your web services API supports it.
The WSDL binding element describes how your web service is bound to a protocol. In other words, how your web service is accessible. To be accessible, the web service must be reachable using some network protocol. This is called “binding” the web service to the protocol.
The WSDL interface element describes the operations supported by your web service. It is similar to methods in the programming language. The client can only call one operation per request.
It describes the endpoint of your web service. In other words, the address where the web service can be reached.
The endpoint element describes the address of the web service. The endpoint binding attribute describes what binding element this endpoint uses.i.e. protocol with which you will access web service. The address attribute describes the URI at which you can access the service.
The message element describes the data being exchanged between the Web service providers and consumers.
Sample WSDL file:
<?xml version=”0.1″ encoding=”UTF-8″?>
<wsdl:definitions targetNamespace=”http://webservices.esaybix.com” xmlns:apachesoap=”http://xml.apache.org/xml-soap” xmlns:impl=”http://webservices.esaybix.com” xmlns:intf=”http://webservices.esaybix.com”
xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” xmlns:wsdlsoap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<!–WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)–>
<schema elementFormDefault=”qualified” targetNamespace=”http://webservices.esaybix.com”
<element name=”name” type=”xsd:string”/>
<element name=”HelloWorldReturn” type=”xsd:string”/>
<wsdl:part element=”impl:HelloWorld” name=”parameters”/>
<wsdl:part element=”impl:HelloWorldResponse” name=”parameters”/>
<wsdl:input message=”impl:HelloWorldRequest” name=”HelloWorldRequest”/>
<wsdl:output message=”impl:HelloWorldResponse” name=”HelloWorldResponse”/>
<wsdl:binding name=”HelloWorldSoapBinding” type=”impl:HelloWorld”>
<wsdlsoap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http”/>
<wsdl:port binding=”impl:HelloWorldSoapBinding” name=”HelloWorld”>
Web service design approaches: