web services a gentle intro martin q. zhao csc colloquium november 8, 2013

28
Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Upload: janie-catt

Post on 31-Mar-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Web Servicesa gentle intro

Martin Q. ZhaoCSC colloquium

November 8, 2013

Page 2: Web Services a gentle intro Martin Q. Zhao CSC 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

Page 3: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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?

Page 4: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 5: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 6: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 8: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 9: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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.

Page 10: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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?

Page 11: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 12: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

A Sample XML Doc

Page 13: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 14: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 15: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 16: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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); };

Page 17: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 18: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 19: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 20: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 21: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

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

Page 22: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Five Steps … - WS Project Folder & Code

Page 23: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Five Steps … - Deploy the WS w/ GlassFish

Page 24: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Five Steps … - Testing WS on localhost

http://localhost:8080/HelloWS/

Page 25: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Five Steps … – generated WSDL & schema

Page 26: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

Five Steps … – client app code & GUI

Page 27: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013

A Hello World Web Service

Service Consumer

Page 28: Web Services a gentle intro Martin Q. Zhao CSC colloquium November 8, 2013