Monday, December 18, 2017

Introduction to WebServices

What is a WebService?
    Definition: Web Service is an application/business logic that is accessible using standard internet protocols via standardized XML messaging system.
·       Web services are communicated using XML's bcoz these XML's are language/platform independent.
·       Integration of heterogeneous applications is possible using Web Services mechanism.
·       Web Service allows you to expose the functionality of your existing code over the network. Once it is exposed to the network, other applications can use the functionality of your code.
·       Here XML messaging system indicate – request & response
·       Bcoz all communications are via XML’s, web services are not dependent on any platform (Operating System) or programming language.
·       There are some specific standards to exchange information b/w web services
SOAP is a XML-based protocol which is responsible for exchanging information b/w web services.
SOAP acronym – Simple Object Access Protocol.
·       SOAP request are sent via HTTP & SOAP responses are returned within the content of the HTTP response
·       Basic web Services communication platform is XML + HTTP

For Eg: Consider 2 applications A (Employee) & B (Third party to verify blacklisted employees). A built on java, B built on Dot net.
App A forms SOAP request bundling all employee details into it and sends over HTTP to App B.
Upon receiving at App B, it un-bundles into its own understanding language, process the request and bundles the response in SOAP format and send it to App A, Again App A unpacks the SOAP message to obtain the results of the request sent



What is WSDL file?
Full form of WSDL is Web Service Description Language
Definition: WSDL describes how to access a web service and what operations it will perform
What are the arguments to pass to invoke particular operations?
What type of data type arguments should pass for the arguments?
What kind of Transport protocol to invoke web service 

Tags inside WSDL File:
wsdl:definitions – defines name of the web service, All other tags which are below are under this tag. WSDL is an XML document with <wsdl:definitions> as root element for all elements

wsdl:types – this defines data types that are used in web service

wsdl:message – this describes how data being exchanged b/w the web services providers & Consumers. Each web service has 2 messages: input & output.

wsdl:portType – can combine one request & one response into single request/response operation.  This is most commonly used in SOAP services. A portType can have multiple operations.
This element has i/p & o/p messages, and each message has name of type tag and in-turn this type tag has data type information of arguments.

wsdl:binding – provides specific details on how portType operation actually be transmitted over the wire. This binding can be made available via multiple transports including HTTP GET, HTTP POST or SOAP.


wsdl:service – defines where to send the service call (destination web service)



What is SOAP ?
Full form of SOAP is Simple Object Access Protocol

SOAP is XML-based protocol for exchanging information b/w web services.
It enables client applications to easily connect remote services and invoke remote methods.
SOAP provides data transport for web services and it is a communication protocol


What is SOAP Message?
A SOAP message is an ordinary XML document which has following elements.
            Envelope (Mandatory): The SOAP envelope tag indicates the start & end of the message so that the receiver knows the entire message has been received.
Every SOAP message has Envelope as root element.
Envelope element is mandatory for a SOAP message

Header (Optional):  Headers are optional attributes of the message used in processing the message. These are intended to add new features & functionality.

             Body (Mandatory): This consists of application defined XML data being exchanged in the SOAP message.

             Fault (Optional): When an error occurs during processing, the response to a SOAP message is SOAP fault element in the body of the message and the fault is returned to the sender of the SOAP message.

 Example SOAP message:
Calculator Add Operation SOAP request
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope” xmlns:tem=”http://tempuri.org/”>

<soap:Header/>
<soap:Body>
              <tem:Add>
                             <tem:a>3</tem:a>
                             <tem:b>4</tem:b>
              </tem:Add>
</soap:Body>

</soap:Envelope>



Other SOAP example webservices for your practice.
Example Web Services for practice

No comments:

Post a Comment