Web Services: Concept, Technologies and Implementation

Zainab Aljazzaf
Supervisor: Dr. Hanan Lutfiyya
University of Western Ontario, Computer science department, Jan 2009
Contents:
• Definition
• Technologies
- SOAP
- WSDL
- UDDI
• Implementation
• References
University of Western Ontario, Computer science department, Jan 2009
What is WS?
•
•
•
Definition.
Technologies.
Implementation.
• A new breed of Web application.
• They are self-contained, self describing,
modular applications that can be published,
located, and invoked across the Web.
• They perform functions, which can be anything
from simple requests to complicated business
processes.
• Once a Web service is deployed, other
applications can discover and invoke it.
University of Western Ontario, Computer science department, Jan 2009
Why WS:
•
•
•
Definition.
Technologies.
Implementation.
• A way to expose system functionality and make
it available through standard web technologies:
- Reduce heterogeneity.
- Key to facilitating application integration.
- Enable new computing paradigm: Service
Oriented Computing.
- Reduce application development costs.
University of Western Ontario, Computer science department, Jan 2009
WS camps?
•
•
•
Definition.
Technologies.
Implementation.
• Web services fall in two categories:
1- Big Web Services (WS-*).
2- RESTful Web Services.
University of Western Ontario, Computer science department, Jan 2009
Service oriented Architecture (SOA)
•
•
•
Definition.
Technologies.
Implementation.
• The Programming paradigm continues to change:
Procedural  Object Oriented  Service Oriented
• SOA is a paradigm for organizing and utilizing distributed
capabilities that may be under the control of different ownership
domains. It provides a uniform means to offer, discover, interact
with and use capabilities to produce desired effects consistent
with measurable preconditions and expectations. OASIS
• SOA is a collection of services that communicate with each
other.
• SOA provides methods for systems development and
integration where systems group functionality around business
processes and package these as interoperable services.
• Aims at a loose coupling of services with operating systems,
programming languages and other technologies.
University of Western Ontario, Computer science department, Jan 2009
Service oriented Architecture (SOA)
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
SOA Protocols:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
WS protocols:
•
•
•
Definition.
Technologies.
Implementation.
• SOAP (Simple Object Access Protocol)
• WSDL (Web Services Description
Language)
• UDDI (Universal Description, Discovery
and Integration)
University of Western Ontario, Computer science department, Jan 2009
WS extend web protocols:
•
•
•
Definition.
Technologies.
Implementation.
• WS extend WWW protocols for supporting
services instead of simple document access:
- SOAP extends HTTP: allow service requests.
- WSDL extends HTML: allow to describe services.
- UDDI extends URI: allow to locate services.
University of Western Ontario, Computer science department, Jan 2009
•
•
•
W3C:
Definition.
Technologies.
Implementation.
If Developers DO have sense:
Future applications will
exchange their data in XML.
We can only pray that all the software
vendors will agree
SOAP, WSDL, UDDI
 XML-based documents
University of Western Ontario, Computer science department, Jan 2009
XML :
•
•
•
Definition.
Technologies.
Implementation.
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
University of Western Ontario, Computer science department, Jan 2009
SOAP:
•
•
•
Definition.
Technologies.
Implementation.
• A lightweight protocol for exchanging structured
information in a decentralized, distributed
environment.
• A communication protocol between applications.
• A format for sending messages.
• XML-based protocol to let applications exchange
information over HTTP.
• A platform and language independent
• Allows to get around firewalls
• A W3C recommendation(24. June 2003).
University of Western Ontario, Computer science department, Jan 2009
Skeleton SOAP Message
•
•
•
Definition.
Technologies.
Implementation.
<?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:Header>
...
</soap:Header>
<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
University of Western Ontario, Computer science department, Jan 2009
•
•
•
SOAP Request:
Definition.
Technologies.
Implementation.
<?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:Header>
<m:Trans xmlns:m="http://www.w3schools.com/transaction/"
soap:mustUnderstand="1"
soap:actor="http://www.w3schools.com/appml/
</m:Trans>
</soap:Header>
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>
University of Western Ontario, Computer science department, Jan 2009
SOAP Response:
•
•
•
Definition.
Technologies.
Implementation.
<?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>
<m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
University of Western Ontario, Computer science department, Jan 2009
WS example: TempConverter
•
•
•
•
Definition.
Technologies.
Implementation.
The following is a sample SOAP 1.1 request and response.
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml;
charset=utf-8
Content-Length: length
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soapenvelope"
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>
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soapenvelope"
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>
</soap:Envelope>
University of Western Ontario, Computer science department, Jan 2009
•
•
•
Soap req/resp:
Definition.
Technologies.
Implementation.
Example from NetBeans:
SOAP Request:
<?xml version="1.0" encoding="UTF8"?>
<S:Envelope
xmlns:S="http://schemas.xmlsoap.org/
soap/envelope/">
<S:Header/>
<S:Body>
<ns2:add
xmlns:ns2="http://cal2.org/">
<i>100</i>
<j>250</j>
</ns2:add>
</S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope
xmlns:S="http://schemas.xmlsoap.org/soap
/envelope/">
<S:Body>
<ns2:addResponse
xmlns:ns2="http://cal2.org/">
<return>350</return>
</ns2:addResponse>
</S:Body>
</S:Envelope>
University of Western Ontario, Computer science department, Jan 2009
WSDL:
•
•
•
Definition.
Technologies.
Implementation.
• Used to describe Web services:
- What the service does?
- Where it located?
- How to invoke it? (data format and
protocol to access the service).
• WSDL is a W3C recommendation (26.
June 2007).
University of Western Ontario, Computer science department, Jan 2009
WSDL document:
•
•
•
Definition.
Technologies.
Implementation.
Interface Definition
Implementation Description
University of Western Ontario, Computer science department, Jan 2009
WSDL document:
•
•
•
Definition.
Technologies.
Implementation.
<definitions>
<types>
Defines the data type uses XML Schema syntax
</types>
<message>
Defines the data elements of an operation.
Each message can consist of one or more parts (parameters).
</message>
Interface
Definition
<portType>
Describes a web service, the operations that can be performed,
and the messages that are involved.
</portType>
<binding>
Defines the message format and protocol details for each port.
</binding>
<service>
Describes a web service. Provide network address of the service.
</service>
</definitions>
Implementation
Description
University of Western Ontario, Computer science department, Jan 2009
WSDL example (abstract)
<message name="getTermRequest">
<part name="term" type="xs:string"/>
</message>
<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
•
•
•
Definition.
Technologies.
Implementation.
Input parameter
Output parameter
Port: function library
Operation: function
Input message
Output message
University of Western Ontario, Computer science department, Jan 2009
WSDL Binding:
•
•
•
Definition.
Technologies.
Implementation.
• WSDL bindings defines the message format and
protocol details for a web service.
<binding type="glossaryTerms" name="b1">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation>
<soap:operation
soapAction="http://example.com/getTerm"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
University of Western Ontario, Computer science department, Jan 2009
WSDL port and operations:
•
•
•
Definition.
Technologies.
Implementation.
• A WSDL port describes the interfaces (legal operations)
exposed by a web service.
University of Western Ontario, Computer science department, Jan 2009
WS:
•
•
•
Definition.
Technologies.
Implementation.
UDDI:
•
•
•
Definition.
Technologies.
Implementation.
• A directory for storing information about web services where
businesses can register and search for Web services.
• Framework for describing and discovering business services,
and service providers.
• Store web service interfaces described by WSDL.
• Communicates via SOAP.
• A platform-independent framework.
• Other alternatives: ebXML (Electronic business XML) and
DSML (Directory Services Markup Language).
• Control of UDDI given to OASIS.
University of Western Ontario, Computer science department, Jan 2009
•
•
•
UDDI*:
Broader
B2B
Smarter
Search
Easier
Aggregation
A mid-sized
manufacturer needs to
create 400 online
relationships with
customers, each with
their own set of
standard and protocols
A flower shop in Australia
wants to be “plugged in”
to every marketplace in
the world, but doesn’t
know how
A B2B marketplace
cannot get catalog data
for relevant suppliers in
its industry, along with
connections to shippers,
insurers, etc.
Definition.
Technologies.
Implementation.
Describe
Services
Discover
Services
Integrate
Them
Together
* http://www.authorstream.com/
University of Western Ontario, Computer science department, Jan 2009
UDDI components:
•
•
•
Definition.
Technologies.
Implementation.
Business description:
- White Pages
Obtaining listings of organizations,
contact info, list of general services
provided
Service description:
- Yellow Pages
Look up information via standardized or
userdefined taxonomies.
- Green pages
Full descriptions of individual web
services. Provided by pointers to service
descriptions, which are usually stored
outside of the registry
Who – What - Where - How
University of Western Ontario, Computer science department, Jan 2009
WS stack:
•
•
•
Definition.
Technologies.
Implementation.
BPEL
UDDI
WSDL
SOAP
HTTP
University of Western Ontario, Computer science department, Jan 2009
University of Western Ontario, Computer science department, Jan 2009
NetBeans:
•
•
•
Definition.
Technologies.
Implementation.
• A free, open-source Integrated Development Environment
(IDE) for software developers.
• Get all the tools you need to create professional desktop,
enterprise, web, and mobile applications.
• Use Java language, C/C++, and even dynamic languages
such as PHP, JavaScript, Groovy, and Ruby.
• Runs on many platforms including Windows, Linux, Mac
OS X and Solaris.
• Dedicated Support Available: programming advice,
software support, and training credits.
• Service Oriented Architecture Support.
University of Western Ontario, Computer science department, Jan 2009
Requirement:
•
•
•
Definition.
Technologies.
Implementation.
• Apache Axis2:
- The core engine for Web services.
- A complete re-design and re-write of the widely
used Apache Axis (an implementation of the
SOAP).
- Provides the capability to add Web services
interfaces to Web applications.
- Function as a standalone server application.
- A server which plugs into servlet engines such as
Tomcat.
- Has support for RESTful web services.
University of Western Ontario, Computer science department, Jan 2009
Architecture:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Cont.
•
•
•
Definition.
Technologies.
Implementation.
• Servlet: Java classes that dynamically process
requests and construct responses.
• Java Servlet API allows a software developer to add
dynamic content (embeds HTML in java).
• Java's replacement for Common Gateway Interface
(CGI) scripts.
• Can almost be thought of as an applet that runs on
the server side.
• Server- and platform-independent.
• Servlet lifecycle is governed by the servlet
container.
University of Western Ontario, Computer science department, Jan 2009
Cont.
•
•
•
Definition.
Technologies.
Implementation.
• JavaServer Pages (JSP): Java technology allows
software developers to dynamically generate HTML,
XML or other types of documents in response to a Web
client request.
• It embeds Java code in HTML (by using <% and %>).
• Enables rapid development of web-based applications
that are server- and platform-independent.
• Architecturally, JSP may be viewed as a high-level
abstraction of servlets.
• JSPs are compiled into Java Servlets by a JSP
compiler.
University of Western Ontario, Computer science department, Jan 2009
Cont.
•
•
•
Definition.
Technologies.
Implementation.
• Apache Tomcat is is a servlet container developed by the
Apache Software Foundation
• An implementation of the Java Servlet and JavaServer Pages
(JSP) technologies.
• A Web container is the component of a Web server that
interacts with the servlets
• Tomcat can act as a simple standalone server for Web
applications that use HTML, servlets, and JSP.
• Provides a "pureJava“ HTTP web server environment for Java
code to run.
• GlassFish is an open source application server project led by
Sun Microsystems for the Java EE platform (Grizzly: the
HTTP frontend of the application server).
University of Western Ontario, Computer science department, Jan 2009
The Setup :
•
•
•
Definition.
Technologies.
Implementation.
• NetBeans IDE (6.5)
- JDK (5 or 6)
- Apache Axis2 (1.4)
- Java web or application server:
- Tomcat web server (6.0.1.8), or
- GlassFish application server (2)
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Create WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Test WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Test WS:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
Result:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
SOAP req/resp:
•
•
•
Definition.
Technologies.
Implementation.
University of Western Ontario, Computer science department, Jan 2009
WSDL:
•
•
•
Definition.
Technologies.
Implementation.
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. -->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. -->
- <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://cal2.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://cal2.org/" name="cal_wsService">
- <types>
- <xsd:schema>
<xsd:import namespace="http://cal2.org/" schemaLocation="http://localhost:8081/Calculator2/cal_wsService?xsd=1" />
</xsd:schema>
</types>
- <message name="add">
<part name="parameters" element="tns:add" />
</message>
- <message name="addResponse">
<part name="parameters" element="tns:addResponse" />
</message>
- <portType name="cal_ws">
- <operation name="add">
<input message="tns:add" />
<output message="tns:addResponse" />
</operation>
</portType>
University of Western Ontario, Computer science department, Jan 2009
Cont.
•
•
•
Definition.
Technologies.
Implementation.
- <binding name="cal_wsPortBinding" type="tns:cal_ws">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="add">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="cal_wsService">
- <port name="cal_wsPort" binding="tns:cal_wsPortBinding">
<soap:address location="http://localhost:8081/Calculator2/cal_wsService" />
</port>
</service>
</definitions>
University of Western Ontario, Computer science department, Jan 2009
References:
•
•
•
Definition.
Technologies.
Implementation.
• W3C : http://www.w3c.org/
• OASIS: http://www.oasis-open.org/home/index.php
• NetBeans: http://www.netbeans.org
• Tomcat: http://tomcat.apache.org/
• Tomcat and Apache web server: http://www.coderanch.com/t/85639/Tomcat/ Differencebetween-Tomcat-Apache-Web
• Tomcate and GlassFish:http://java.dzone.com/articles/glassfish-and-tomcat-whats-the
• Servlet and JSP: http://www.servlets.com/soapbox/problems-jsp.html
• Web container and web server: http://www.coderanch.com/t/176596/Web-ComponentCertification-SCWCD/certification/Web-Container-Web-server
•Cesare Pautasso, Olaf Zimmermann, Frank Leymann, RESTful Web Services vs. “Big” Web
Services:Making the Right Architectural Decision. pp. 805-814, Proceedings of the 17th
International World Wide Web Conference, ACM Press, China, April 2008.
•Seekda: the largest search engine for public Web Service: http://seekda.com/
• WS standards overview: http://www.innoq.com/soa/ws-standards/poster/innoQ %20WSStandards%20Poster%202007-02.pdf
University of Western Ontario, Computer science department, Jan 2009
Thank you ..
University of Western Ontario, Computer science department, Jan 2009