Web Services - How it works



Let's begin with a real life scenario. Suppose a client side C++ application wants to get data from a server side JAVA application. How is this possible? 
There are two challenges to make this communication:

  1. Two different language is used, so the behavior of the applications are different
  2. Server side Java application won't allow the client directly access to it's resources such as database, files etc due to security reason.
  3. Client don't know about the implementation details of Server application

At this situation we need a Web Service to make the solution. Here is how Web Services basically works:

  • WSDL: WSDL is Web Service Descripting Language. 
    • To get information from server (or any other applications), client application needs to know the implementation details of the server application
    • Server publishes the implementation details over an XML file is called WSDL
    • XML file contains ClassName, MethodName and other Parameters you need to get data from one applications to another. 
    • WSDL XML also contain EndPoingUrl that provides location where the Web Services are running currently
    • XML have chosen as a communicating language because it is an universal language, can be read and understand by any application made over versatile platform. No matter which language or platform the communicating applications are built on.
  • UDDI: UDDI stands for Universal Description, Discovery, and Integration. 
    • UDDI is a specification for a distributed registry of web services. 
    • UDDI is a platform-independent, open framework. UDDI can communicate via SOAP, CORBA, Java RMI Protocol. 
    • UDDI uses Web Service Definition Language(WSDL) to describe interfaces to web services.
    • WSDL XML is stored to UDDI Registry Software with a unique name. 
    • Client application know this unique name and location of UDDI Software
    • Client side application calls UDDI for the unique  WSDL XML with the given unique name.
  • STUB: A stub is a small program routine that substitutes for a longer program, possibly to be loaded later or that is located remotely.
    • Using some STUB(Proxies) Generating tools, client will generate STUB class with the WSDL XML file.
    • This STUB Class will be in the same language on which the client application built on. For example if a client application is built on C++/PHP/ANDROID/C# then the STUB will be a class written in C++/PHP/ANDROID/C# respectively
    • STUB Class will contain the method written in WSDL XML format sent from the server application
    • Now the STUB Class is called by creating its object in the client application
Using this STUB object now Client application can access the data from the server applications databases, files and other resources.

Comments