50
SOAP-based Web Services Web Technology 2II25 Dr. Katrien Verbert Dr. ir. Natasha Stash Dr. George Fletcher

SOAP-based Web Services

Embed Size (px)

Citation preview

Page 1: SOAP-based Web Services

SOAP-based Web Services Web Technology 2II25

Dr. Katrien Verbert Dr. ir. Natasha Stash Dr. George Fletcher

Page 2: SOAP-based Web Services

Contents

•  Big Web Services •  SOAP, WSDL and UDDI •  Comparison RESTful Web Services

•  Next lecture •  JAX-WS: Building SOAP-based services in Java •  JAXB: SOAP and XML processing •  JAX-RS: Building RESTful services in Java

Page 3: SOAP-based Web Services

What Are Web Services?

Page 4: SOAP-based Web Services

Web Services, Web Applications and APIs (Application Programming Interface)

•  Web Applications == Web Services == Web APIs ?

Page 5: SOAP-based Web Services

Web Services, Web Applications and APIs (Application Programming Interface)

•  Web Applications are designed to be accessed by end users through Web client software

•  Web Services are intended to be used by other software applications

•  Web APIs ≈ Web Services

Page 6: SOAP-based Web Services

Example Mashup: Last on AM/FM

http://people.cs.kuleuven.be/~sten.govaerts/lastonamfm/ http://www.programmableweb.com/mashup/last-on-am-fm

Page 7: SOAP-based Web Services

Example web client application

http://ariadne.cs.kuleuven.be/alocom/alocom_plugin/alocom_plugin.swf

Page 8: SOAP-based Web Services
Page 9: SOAP-based Web Services

Disaggregation service

Page 10: SOAP-based Web Services

What Are Web Services?

•  W3C definition: •  “A software system designed to support interoperable

machine-to-machine interaction over a network...”

Page 11: SOAP-based Web Services

Web Services Use

•  Connect existing software •  Reusable application components

Page 12: SOAP-based Web Services

Terminology

•  Major classes of Web Services: •  Big Web Services •  (L. Richardson and S. Ruby) •  RESTful (REST-compliant) Web Services

•  Service-Oriented Architecture (SOA) •  The Competing Web Service Architectures: •  (L. Richardson and S. Ruby):

•  RPC-Style Architectures (Remote Procedure Calls) •  RESTful, Resource-Oriented Architectures (ROA) •  REST-RPC Hybrid Architectures

Page 13: SOAP-based Web Services

Web Service Technologies

•  Basic Web Services platform: •  XML+HTTP

•  Related to Big Web Services: •  SOAP (Simple Object Access Protocol) •  WSDL (Web Services Description Language) •  UDDI (Universal Description, Discovery, and

Integration)

Page 14: SOAP-based Web Services

Roles and Operations in a Service-Oriented Architecture (SOA)

Service Requester

Service Broker

Service Provider

Find Publish

Bind

Page 15: SOAP-based Web Services

Goals of SOA

•  separation of concerns •  loose coupling among interacting software applications •  reusability of services •  interoperability

Page 16: SOAP-based Web Services

The Standards, Components and Relationships for Big Web Service Implementation

Service Requester

(Web Service client)

2) Find Web Service

1) Publish Web Service

4) Invoke Web Service

Service Provider (Web

Service)

Service Broker (UDDI registry)

3) Download WSDL

Page 17: SOAP-based Web Services

What is SOAP

•  SOAP used to stand for Simple Object Access Protocol •  SOAP is a communication protocol •  SOAP is designed to communicate via Internet •  SOAP is based on XML •  SOAP is simple and extensible •  SOAP is platform and language independent •  SOAP is a W3C standard

Page 18: SOAP-based Web Services

SOAP Message Structure

SOAP Envelope

SOAP Header

SOAP Body

header block

<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> ... </env:Header> <env:Body> ... <env:Fault> ... </env:Fault> </env:Body> </env:Envelope>

body block

Page 19: SOAP-based Web Services

SOAP Example: RPC-Style Request Message <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> <ts:getPrice xmlns:ts="http://travelagency.example.org/wsdl/trips" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding"> <ts:departing>Amsterdam (Schiphol)</ts:departing> <ts:arriving>Saint-Petersburg (Pulkovo)</ts:arriving> <ts:departureDate>01-05-2010</ts:departureDate> <ts:/getPrice> </env:Body> </env:Envelope>

Request

<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">

<env:Body> <ts:getPriceResponse xmlns:ts="http://travelagency.example.org/wsdl/trips" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding" > <ts:price>180.00</ts:price> </ts:getPriceResponse> </env:Body> </env:Envelope>

Response

Page 20: SOAP-based Web Services

RPC-Style Architectures

•  Envelopes exchange between Web Service and its client

•  Kinds of envelopes: •  HTTP •  SOAP

Page 21: SOAP-based Web Services

SOAP Example: Conversational Message Exchanges

<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> ... <ts:arriving> <ts:arrivingChoices>airport1 airport2 airport3</ts:arrivingChoices> </ts:arriving> ... </env:Body> </env:Envelope>

<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body>

... <ts:arriving>airport1</ts:arriving> ... </env:Body> </env:Envelope>

Response

Request

Page 22: SOAP-based Web Services

Fault Scenarios

x

<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"

xmlns:rpc='http://www.w3.org/2003/05/soap-rpc'> <env:Body> <env:Fault> <env:Code> <env:Value>env:Sender</env:Value> <env:Subcode> <env:Value>rpc:BadArguments</env:Value> </env:Subcode> </env:Code> <env:Reason> <env:Text xml:lang="en-US">Processing error</env:Text> </env:Reason> </env:Fault> </env:Body> </env:Envelope>

Page 23: SOAP-based Web Services

SOAP HTTP Binding: SOAP HTTP Post Usage

POST /pricesService/getPrice HTTP/1.1 Host: http://travelagency.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> <ts:getPrice xmlns:ts="http://travelagency.example.org/wsdl/trips"> <ts:departing>Amsterdam (Schiphol)</ts:departing> <ts:arriving>Saint-Petersburg (Pulkovo)</ts:arriving> <ts:departureDate>21-04-2010</ts:departureDate> <ts:/getPrice> </env:Body> </env:Envelope>

Page 24: SOAP-based Web Services

SOAP HTTP Binding: SOAP Response

HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> <ts:getPriceResponse xmlns:ts="http://travelagency.example.org/wsdl/trips"> <ts:price>180.00</ts:price> </ts:getPriceResponse> </env:Body> </env:Envelope>

Page 25: SOAP-based Web Services

What is WSDL

•  WSDL stands for Web Services Description Language •  WSDL is used to describe and locate Web Services •  WSDL is based on XML •  WSDL is a W3C standard

Page 26: SOAP-based Web Services

WSDL

Describes three fundamental properties •  What a service does

•  Operations (methods) provided by the service •  How a service is accessed

•  Data format and protocol details •  Where a service is located

•  Address (URL) details

Page 27: SOAP-based Web Services

WSDL Document Structure

Main structure of WSDL document <definitions targerNamespace=“...”> <types>definition of types...</types> <message>definition of a message...</message> <portType>definition of a port</portType> <binding>definition of a binding...</binding> <service> <port>...</port> </service> </definitions>

WSDL Specification

abstract part

concrete part

types

messages

operations

port types

bindings

service

port

Page 28: SOAP-based Web Services

WSDL Document Example: Abstract Part <message name="itineraryMsg"> <part name="departing" type="xs:string"/> <part name="arriving" type="xs:string"/> <part name="departureDate" type="xs:date"/> </message> <message name="itineraryRespMsg"> <part name="price" type="xs:string"/> </message> <portType name="pricesPT"> <operation name="getPrice"> <input message="itineraryMsg"/> <output message="itineraryRespMsg"/> </operation> </portType>

Page 29: SOAP-based Web Services

Operation Types

Type Definition

One-way The operation can receive a message but will not return a response

Request-response

The operation can receive a request and will return a response

Solicit-response The operation can send a request and will wait for a response

Notification The operation can send a message but will not wait for a response

Page 30: SOAP-based Web Services

Example: One-Way Operation

<message name="newPrices"> <part name="departing" type="xs:string"/> <part name="arriving" type="xs:string"/> <part name="departureDate" type="xs:date"/> <part name="price" type="xs:string"/> </message> <portType name="pricesPT"> ... <operation name="setPrice"> <input message="newPrices"/> </operation> </portType >

Page 31: SOAP-based Web Services

WSDL Document Example: Concrete Part

<service name="pricesService"> <port name="getPriceRPCPort" binding="ts:b1"> <soap:address location="http://travelagency.example.org/pricesService"> </port> </service>

xmlns:ts='http://travelagency.example.org/wsdl/trips'

Page 32: SOAP-based Web Services

WSDL Document Example: Concrete Part <binding name="b1" type="ts:getPriceRPCPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="ts:getPrice"> <input> <soap:body use="encoded" namespace="http://travelagency.example.org/wsdl/trips" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" /> </input> <output> <soap:body use="encoded" namespace="http://travelagency.example.org/wsdl/trips" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" /> </output> </operation> ... </binding>

xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'

Page 33: SOAP-based Web Services

What is UDDI

•  UDDI stands for Universal Description, Discovery and Integration •  UDDI a standard for publishing and discovering Web services •  UDDI is a specification for a distributed registry of Web services •  UDDI is built upon standards such as HTTP, XML, XML Schema,

SOAP, WSDL •  UDDI can communicate via SOAP, CORBA, Java RMI Protocol •  UDDI uses WSDL to describe interfaces to Web Services

Page 34: SOAP-based Web Services

Ways to Use UDDI Registry

•  White pages –  name, address, contact person, Web site •  Yellow pages –  types of business, locations, products, services,

categorizations •  Green pages –  technical information about business services, pointers to

WSDL descriptions of the services

Page 35: SOAP-based Web Services

UDDI Data Model: UDDI Core Data Types

Example: http://www.tutorialspoint.com/uddi/uddi_data_model.htm

Page 36: SOAP-based Web Services

UDDI Data Model: tModel example

<?xml version="1.0"?> <tModel tModelKey="”>

<name>http://www.getquote.com/StockQuoteService-interface</name> <description xml:lang="en">…</description> <overviewDoc>

<description xml:lang="en”>WSDL Service Interface Document </description> <overviewURL> http://www.getquote.com/services/SQSinterface.wsdl#SingleSymbolBinding </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey="UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4” keyName="uddi-org:types" keyValue="wsdlSpec"/> <keyedReference tModelKey="UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384” keyName="Stock market trading services” keyValue="84121801"/>

</categoryBag> </tModel>

Page 37: SOAP-based Web Services

UDDI: Programmatic Interfaces

•  UDDI Inquiry Interface: –  find_business, find_service, find_tModel, find_binding,

find_relatedBusiness –  get_businessDetail, get_serviceDetail, get_bindingDetail,

get_tModelDetail •  UDDI Publisher Interface: –  save_business, save_service, save_binding, save_tModel –  delete_business, delete_service, delete_binding,

delete_tModel –  ...

Page 38: SOAP-based Web Services

Big Web Services Examples

•  http://www.xmethods.com •  http://www.programmableweb.com/

Page 39: SOAP-based Web Services

Web services enable

1.  data exchange between various applications and different platforms 2.  to resolve interoperability issues 3.  applications to function between two different operating systems server 4.  all of the above

Page 40: SOAP-based Web Services

Coding and decoding, and transporting the data is performed by

1.  XML and UDDI respectively 2.  XML and SOAP respectively 3.  HTML and HTTP respectively 4.  HTML and SOAP respectively

Page 41: SOAP-based Web Services

Which of the following is used to locate and describe web services?

1.  SOAP 2.  Web page 3.  WSDL 4.  UDDI

Page 42: SOAP-based Web Services

Why SOAP is used as a protocol for accessing a web service?

1.  SOAP platform and language independent, allows to get around firewalls 2.  SOAP is based on HTML 3.  SOAP is designed to communicate through LAN 4.  All of the above

Page 43: SOAP-based Web Services

03/28/11

Big Web Service Operations vs RESTful Web Service URIs

Big WS operations

RESTful WS URIs

getAllUsers() http://example.com/users/ "

getUserById() http://example.com/users/id/<user-id>

getUserByName(), addUser() removeUser(), updateUser()

http://example.com/users/name/<user-name>

Page 44: SOAP-based Web Services

03/28/11

Big Web Services versus REST

A SOAP service has a single endpoint •  that handles all the operations •  therefore it has to have an application-specific interface. A RESTful service has a number of resources •  so the operations can be distributed onto the resources •  and mapped to a small uniform set of operations.

Page 45: SOAP-based Web Services

Comparison: Big Web Services vs RESTful Web Services

•  How the client conveys its intentions to the server? Where method information is kept?

•  How the client tells the server which part of the data set to operate on? Where is scoping information kept?

–  Big Web Services: in the entity body –  RESTful Web Services: in the URI path

–  Big Web Services: in HTTP header and entity body –  RESTful Web Services: in HTTP header

Page 46: SOAP-based Web Services

Comparison: Big Web Services vs RESTful Web Services

•  Big Web Services pros: –  protocol transparency and independence –  existence of tools to hide the complexity –  security

•  Big Web Services cons:

–  rudimentary processing protocol –  complexity –  heavyweight architecture –  do not get the benefits of resource-oriented services –  opaqueness

Page 47: SOAP-based Web Services

Comparison: Big Web Services vs RESTful Web Services

•  Big Web Services are the preferred option for enterprise application integration

•  RESTful Web services are well suited for basic, ad hoc integration scenarios over Web (Mashup)

Page 48: SOAP-based Web Services

Comparison: Big Web Services vs RESTful Web Services

•  RESTful Web Services pros: –  simplicity –  lightweight infrastructure –  addressability –  uniform interface –  scalability of stateless RESTful Web Service –  improved performance using JSON

•  RESTful Web Services cons: –  bound to one protocol: HTTP –  only POST and GET can be used in XHTML form –  dealing with large input data - “malformed” URI –  security issues

Page 49: SOAP-based Web Services

Recommended reading

Cesare Pautasso,Olaf Zimmermann,Frank Leymann (2008) RESTful Web Services vs. Big Web Services: Making the Right Architectural Decision. Proc. of the 17th International World Wide Web Conference (WWW2008), Bejing, China, April 2008.