Introductio
n to
  Web
Services
Web Services
• A Web service is a method of communication
  between two electronic devices over
  the World Wide Web
• In other words, a web service helps to convert
  your application into a web-based application.
Why web services?
• Your application can publish its function or
  message to the rest of the world.
WEB
               Services

REST Services               SOAP and WSDL



   Department of Information Science Engg
REST Services
• Relying on URIs and HTTP verbs
• Usage of 5 big HTTP verbs
  POST, HEAD, GET, PUT, DELETE
  Nothing more than CRUD concept of the Web
• Ex: Delicious APIs
  Delicious is a leading social bookmarking service
  Visit: http://www.peej.co.uk/articles/restfully-delicious.html
• Data exchange format
  XML, JASON or both
SOAP based services
• Simple Object Access Protocol
• Exclusively use XML as the data format to exchange info
  over HTTP.
• A service that needs to be used by another service needs
  to specify its usage through a “Service Description”.
• In this case, we use WSDL – Web Services Description
  Language
• Ex: Apache Axis, Apache CXF
• SOAP has nothing to do with SOA – Service Oriented
  Architecture
.
• A service is hosted on a “Discovery Service” in the internet.
• A client which wants to use this service will have to “discover”
 this service (similar to RMI) using the ‘Discovery Service’.
• Once the service is “discovered”, the client asks the service
 how it should be invoked. The service replies in WSDL format.

• The service is now invoked using SOAP. The client issues a
 ‘SOAP Request’.

• The service responds with a ‘SOAP Response’, which includes
 the result.
A SOAP message is an ordinary XML document
containing the following elements:
• Envelope - identifies the XML document as a SOAP message
    o Header - contains information about the request.
    o Body
         Message data - contains request and response information
           itself.
         Fault (optional) - containing errors and status information.
A SOAP request:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-
envelope"
soap:encodingStyle="http://www.w3.org/2001/12/
soap-encoding">

<soap:Body
xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>
The SOAP response:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/
soap-envelope"
soap:encodingStyle="http://www.w3.org/
2001/12/soap-encoding">

<soap:Body
xmlns:m="http://www.example.org/stock"
>
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>

</soap:Envelope>
WSDL
• WSDL stands for Web Services Description Language
• It is an XML-based language that is used for
  describing the functionality offered by a Web service.
• WSDL file contains info about
   o   How the service can be called
   o   What parameter it expects
   o   What data structure it returns
   o   Which port the application uses
   o   Which protocol the web service uses (like https)
Need for stubs (similar to RMI)
What are stubs?
• A stub is a small program routine that substitutes for
  a longer program, possibly to be loaded later or that
  is located remotely.
• The stub accepts the request and then forwards it
  (through another program) to the remote procedure.
• When that procedure has completed its service, it
  returns the results or other status to the stub which
  passes it back to the program that made the request.
Comparision
REST services                     SOAP services
• Architectural style             • XML-based protocol
• Simply calls services via URL   • Invokes services by calling
  path                              RPC method
• Lightweight – not a lot of      • Rigid – type checking,
  extra xml markup                  adheres to a contract
• Easy to build – no toolkits     • Development tools – WSDL
  required                          Soap analyser tool, oXygen
                                    XML
Web Services -  A brief overview

Web Services - A brief overview

  • 1.
    Introductio n to Web Services
  • 2.
    Web Services • AWeb service is a method of communication between two electronic devices over the World Wide Web • In other words, a web service helps to convert your application into a web-based application.
  • 3.
    Why web services? •Your application can publish its function or message to the rest of the world.
  • 4.
    WEB Services REST Services SOAP and WSDL Department of Information Science Engg
  • 5.
    REST Services • Relyingon URIs and HTTP verbs • Usage of 5 big HTTP verbs POST, HEAD, GET, PUT, DELETE Nothing more than CRUD concept of the Web • Ex: Delicious APIs Delicious is a leading social bookmarking service Visit: http://www.peej.co.uk/articles/restfully-delicious.html • Data exchange format XML, JASON or both
  • 6.
    SOAP based services •Simple Object Access Protocol • Exclusively use XML as the data format to exchange info over HTTP. • A service that needs to be used by another service needs to specify its usage through a “Service Description”. • In this case, we use WSDL – Web Services Description Language • Ex: Apache Axis, Apache CXF • SOAP has nothing to do with SOA – Service Oriented Architecture
  • 7.
  • 8.
    • A serviceis hosted on a “Discovery Service” in the internet. • A client which wants to use this service will have to “discover” this service (similar to RMI) using the ‘Discovery Service’. • Once the service is “discovered”, the client asks the service how it should be invoked. The service replies in WSDL format. • The service is now invoked using SOAP. The client issues a ‘SOAP Request’. • The service responds with a ‘SOAP Response’, which includes the result.
  • 9.
    A SOAP messageis an ordinary XML document containing the following elements: • Envelope - identifies the XML document as a SOAP message o Header - contains information about the request. o Body  Message data - contains request and response information itself.  Fault (optional) - containing errors and status information.
  • 10.
    A SOAP request: <?xmlversion="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap- envelope" soap:encodingStyle="http://www.w3.org/2001/12/ soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
  • 11.
    The SOAP response: <?xmlversion="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/ soap-envelope" soap:encodingStyle="http://www.w3.org/ 2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock" > <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
  • 13.
    WSDL • WSDL standsfor Web Services Description Language • It is an XML-based language that is used for describing the functionality offered by a Web service. • WSDL file contains info about o How the service can be called o What parameter it expects o What data structure it returns o Which port the application uses o Which protocol the web service uses (like https)
  • 14.
    Need for stubs(similar to RMI)
  • 15.
    What are stubs? •A stub is a small program routine that substitutes for a longer program, possibly to be loaded later or that is located remotely. • The stub accepts the request and then forwards it (through another program) to the remote procedure. • When that procedure has completed its service, it returns the results or other status to the stub which passes it back to the program that made the request.
  • 17.
    Comparision REST services SOAP services • Architectural style • XML-based protocol • Simply calls services via URL • Invokes services by calling path RPC method • Lightweight – not a lot of • Rigid – type checking, extra xml markup adheres to a contract • Easy to build – no toolkits • Development tools – WSDL required Soap analyser tool, oXygen XML