Fabricio Breve 1,2 [email protected] Liang Zhao 2 [email protected]
Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013.
-
Upload
janie-catt -
Category
Documents
-
view
214 -
download
1
Transcript of Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013.
Web Servicesa gentle intro
Martin Q. ZhaoCSC colloquium
November 8, 2013
Components and Services The Evolution of Distributed Computing The Concept of Web Services WS-related Technologies Create, Publish, and Consume a WS
Outline
Service in everyday context: work done for somebody else (Bing dictionary) the work performed by one that serves (Webster)
What are the advantages of a service? Expertise Efficiency and cost effectiveness Reusability (everyone can request the same
service) Loosely coupling (no need to worry about how it’s
done)
What is a Service?
Service in software context: task performed by one app (server) for
another app (client) Software component:
Provides a service that confirms to a set of required operations
E.g., DBMS provides CRUD operations
Service in Software
Also known as distributed architecture Break up application logic and distribute
cohesive chunks of functions (services) into loosely coupled reusable modules (components)
Make building complexsystems easier
Component-Based Design
Web Server
Application Server
Fundamental tasks of software applications = automating information transformation processes Organize information: define and store Perform transformation: manipulating data based
on application logic Applications can share data and operations
Students/professors/deans/registrars share course data
Various E-Business sites use FedEx delivery service (including operations like pricing, tracking, etc.)
Data and Operations
Sharing Data: Asynch. vs. Synch.
Appl. A
Appl. B
File
write read
Appl. B Appl.
Dread
read
Database
Appl. A
Appl. C
write
read
Appl. A
Appl. B
Shared Memor
y
Appl. B
Appl. A
Service-Based Integration
Web Services
Messaging
Object Request Brokers (ORBs)
Remote Procedure Call
(RPC)
Sockets - Connectivity- Real-time data
sharing
- Functionality sharing
- Interface description
- Platform independent
- Language independent interface [IDL]
- Initial concept of registry- Separate n/w & marshaling
- Separate n/w & marshaling
- Scalable connectivity- Guaranteed delivery
- Middleware independent data format [XML]
- Refined concept of registry [UDDI]- Refined interface definition [WSDL]- SOAP
• Data sharing only
• Limited data type
• Tightly coupled
Aka Client/Server
Aka distributed
objects
A WS is a SW service accessible on the Web. A Web service is a software function provided
at a network address over the web or the cloud, and it is "always on" (as in the concept of utility computing) .
The W3C defines a "Web service" as:
What is a Web Service?
[...] a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.
Web services are abound with a number of standards XML: machine-independent communication
language HTTP-based: supported by all operating
systems WSDL: XML-based interface description
language SOAP (simple object access protocol):
specification for exchanging structured information
UDDI (Universal Description, Discovery and Integration ): common means for service lookup
How Does It Work?
Extensible Markup Language W3C standard since late 90’s : fundamental to WS Use tags to markup contents (in Unicode character
set) and relationships among them Use DTD (document type definition) and later XSD
(XML Schema Definition) to define schema and validate docs
Advantages for WS Independent from H/W and S/W platforms Support any structure yet maintain it in transit
XML
A Sample XML Doc
Web Services Description Language (since 2001) Programming language and middleware
independent Free to choose a communication protocol Free to choose any convenient message format
(SOAP, RESTful + XML/JSON, XML RPC, etc) A wide range of service operations to choose
from (synch, asynch, RESTful, SOAP) A service end point (N/W address) can be
specified
WSDL
Typical Message Formats<?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>
... message data ...
<soap:Fault> </soap:Fault>
</soap:Body>
</soap:Envelope>
{ firstName : "Jakob", lastName : "Jenkov", address : { street : "The Road 123", zip : "12345", city : "Copenhagen" } }
<profile> <firstName>Jakob</firstName> <lastName>Jenkov</lastName> <address> <street>The Road 123</street> <zip>12345</zip> <city>Copenhagen</city> </address> </profile>
SOAP
XML
JSON
Universal Description, Discovery and Integration Platform-independent, XML-based registry Three components
White page: address, name Yellow page: categories Green pages: tech info
The process Service provide publishes WSDL Service consumer looks up WS Service consumer consumes WS
UDDI
WS vs. Distributed Objects
Service Consumer CORBA –
common object request broker
architecture
[ object, uuid(a03d1420-b1ec-11d0-8c3a-00c04fc31d2f), ] interface IFace1 : IUnknown { HRESULT MethodA([in] short Bread, [out] BKFST * pBToast); HRESULT MethodB([in, out] BKFST * pBPoptart); };
Commonly Used Web Services
Get five days weather report for a given zip code (USA)
Get FedEx shipping rate Get the Barnes & Noble
price by ISBN Get name and address
data associated to any telephone number
Call any phone number and speaks text or sound file to the person.
Instantly determines the distance between two U.S. ZIP codes.
Get historical end of day data for U.S. stock options
A B2C Case Study – Call a Cab
The E-Business 1.0 experience
iQTaxi by qSent.com in 2001RPC-style WS provided for 3rd party integration
Call iQTaxi Call Center or through web pageLook up nearby dispatcher numbersText the caller with three numbers
iQTaxi got paid by dispatchers
A B2C Case Study – Call a Cab (cont’d)
Request a ride from a smart phone
Set pickup location (text or app)
View car/driver info while waiting
Got text notification twice (time-to-arrive and arrive) Got charged to credit card automatically when done
Uber: An E-Business 2.0 experienceMade to the news in 2011Mash-up w/ GoogleMap for real-time interactions
How to Create a WS – in Java?
Resources the you will need Java Enterprise Edition (JEE 7) A Java Application Server (such as GlassFish 4) A Web Server (such as Apache 2.4) Ideally an IDE for JEE (such as NetBeans 7.4)
Design decisions to make before coding Operations to provide get name & say hello Message format to use SOAP
Five Steps to Completion
Creating a Web Application project An umbrella for a web, source, and WS folders
Adding a Web Service class w/ a desired name
Defining the Web Service Specify service and method names, as well as
parameters Publishing and testing the Web Service Creating a client app to consume the WS
Five Steps … - WS Project Folder & Code
Five Steps … - Deploy the WS w/ GlassFish
Five Steps … - Testing WS on localhost
http://localhost:8080/HelloWS/
Five Steps … – generated WSDL & schema
Five Steps … – client app code & GUI
A Hello World Web Service
Service Consumer