Lecture 10 - SOA-3
Lecture 10 - SOA-3
Design
SWE30003
Software Architectures and Design
Lecture 10
Service Oriented Architectures (SOA) and
Web Services
Logistical matters
Weekly submissions – A & Q
Week 2: 361 & 346 out of 434;
Week 3: 380 & 366 out of 434;
Week 4: 395 & 393 out of 434;
Week 5: 398 & 389 out of 432;
Week 6: 379 & 375 out of 430;
Week 7: 326 & 320 out of 430;
Week 8: 359 & 348 out of 430,
Week 9:
Week 10:
No late submission, hurdle requirement
Assignment 3: … Questions? 2
Additional Resources/Readings
Follow the links provided …
Michael Papazoglou: Web Services: Principles and
Technology, Pearson/Prentice Hall, 2008. Chapters 1 & 2
(and more)
Leonard Richardson and Sam Ruby: RESTful Web
Services, O’Reilly, 2007. Chapter 1 (and more)
Webber, Parastatidis, Robinson: REST in Practice, O’Reilly,
2010 (Free download http://it-ebooks.info/book/393/)
InfoQ (http://www.infoq.com): SOA, Web services, REST,
Microservices, Enterprise Architecture, …
5
Content
The Web
Distributed
Searchable/addressable
Extensible/unbounded
…
7
10
11
12
12
13
Content
14
14
15
15
Some concepts …
16
Some concepts …
Granularity
Service granularity:
Simple services are discrete in nature, exhibit normally a
request/reply mode of operation & are of fine granularity, i.e.,
they are atomic in nature.
Complex services are coarse-grained, e.g., a PurchaseOrder.
These involve interactions with other services and possibly end-
users in a single or multiple sessions.
Coarse-grained communication implies larger and richer data
structures, (viz. those supported by XML).
17
17
Some concepts …
18
18
Some concepts …
19
19
What How to
does it represent it? How to
do? build it?
Interface
How do I Implementation
use it?
Where Where to
can I find How to host it?
it? publish it?
20
20
Some concepts …
Loose Coupling
Coupling indicates the degree of dependency any two systems have on
each other. Some types relevant to enterprise computing include:
Type of Coupling Problem Description Reduced by
Functional One module relies on the Well defined interface/API describing inputs and
internal workings of others outputs
Interface Interfaces reflect the Avoid detailed mandatory parameters;
implementation details Use more general methods and message
passing (do not get too fine-grained)
Data Structure Data passed between Explicitly define formats, e.g XML in interface;
modules reflects internal Allow multiple representations e.g.mime-types;
representations, ‘Vertical’ standards that define semantics of
or is over-constrained messages
Temporal Client blocked while Asynchronous messages; Explicitly define
waiting response behaviour in interface e.g. abstract BPEL;
Process over-constrained Interaction via events / event-driven processes
Address/URI Addresses change Do not hard code references;
Providers change Virtualise services; 21
URI patterns change Use middleware directory services
21
Content
22
22
Service
Description
Service
Service
Service
Publish
Provider Service
1 Registry
Description
23
23
Resource-oriented
Interface: generic CRUD, Resource id, Media type
Interaction: synchronous request-response, request-acknowledge
Event-oriented
24
Interface: event type
Interaction: Subscribe-notify, publish-subscribe-notify
24
RPC-style programming
leads to tight coupling of
interfaces and applications. Network
25
reply reply
26
26
Message-oriented Middleware
MOM is an infrastructure that involves the passing of data between
applications using a common communication channel that carries
self-contained messages.
Messages are sent and received asynchronously.
The messaging system (integration broker) is responsible for
managing the connection points between clients & for managing
multiple channels of communication between the connection points.
Client Client Server
Message Message
Application logic
publication notification
MOM MOM MOM
27
27
Resource-oriented Architecture
Resources exposed on a network
Resources uniquely identified
Application is a series of linked resource updates between clients
and servers
Resource examples
CRUD:
something returned by an SQL query Create, Read,
text or media file Update, Delete
a transaction
a web site
a downloadable program
...
28
28
29
Functional One module relies on the Well defined interface/API describing inputs and
internal workings others outputs
Interface Interfaces reflect the Avoid detailed mandatory parameters;
implementation details Use more general methods and message
passing (do not get too fine-grained)
Data Structure Data passed between Explicitly define formats, e.g XML in interface;
modules reflects internal Allow multiple representations e.g.mime-types;
representations, ‘Vertical’ standards that define semantics of
or is over-constrained messages
Temporal Client blocked while Asynchronous messages; Explicitly define
waiting response behaviour in interface e.g. abstract BPEL;
Process over-constrained Interaction via events / event-driven processes
Address/URI Addresses change Do not hard code references;
Providers change Virtualise services;
URI patterns change Use middleware directory services
30
30
Content
31
31
32
RPC
WS* (SOAP, WDSL, …)
Message-oriented
RESTful / Microservices
Resource-oriented
Event-oriented
33
????
Which architectural style is the most “decoupled”?
Which architectural style is the hardest to change /
evolve? a.k.a “Fragile”
34
34
Content
35
35
37
38
38
39
Interface descriptions
Structure of WSDL documents
Abstract part
Concrete part
40
40
An example:
in programming language style (illustration only)
Service StokeQuote {
//types
struct TradePriceRequestType { //RPC
string tickerSymbol;
};
struct TradePriceType{
float price;
};
Interface StokeQuotePortType {
void GetLastTradePrice
(in TradePriceRequestType GetLastTradePriceInput,
out TradePriceType GetLastTradePriceOutput);
……
};
};
41
41
42
42
43
43
44
44
<wsdl:definitions name="PurchaseOrderService"
targetNamespace="http://supply.com/PurchaseService/wsdl"
xmlns:tns="http://supply.com/ PurchaseService/wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Example of
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
Abstract data type
Abstract WSDL
<xsd:schema definitions
targetNamespace=http://supply.com/PurchaseService/wsdl>
Interface definition
<xsd:complexType name="CustomerInfoType">
<xsd:sequence>
<xsd:element name="CusNamer" type="xsd:string"/>
<xsd:element name="CusAddress" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="POType">
<xsd:sequence>
<xsd:element name="PONumber" type="integer"/>
<xsd:element name="PODate" type="string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="InvoiceType">
<xsd:all>
<xsd:element name="InvPrice" type="float"/>
<xsd:element name="InvDate" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema> Data that is sent
</wsdl:types>
<wsdl:message name="POMessage">
<wsdl:part name="PurchaseOrder" type="tns:POType"/>
< wsdl:part name="CustomerInfo" type="tns:CustomerInfoType"/>
</wsdl:message>
<wsdl:message name="InvMessage"> Data that is returned
<wsdl:part name="Invoice" type="tns:InvoiceType"/>
</wsdl:message> Port type with
<wsdl:portType name="PurchaseOrderPortType"> one operation
<wsdl:operation name="SendPurchase">
<wsdl:input message="tns:POMessage"/>
An operation with
<wsdl:output message="tns:InvMessage"/>
request (input) &
</wsdl:operation>
response (output)
45
</wsdl:portType>
</wsdl:definitions> message
45
<wsdl:definitions> . …
<import namespace="http://supply.com/PurchaseService/wsdl"
location="http://supply.com PurchaseService/wsdl/PurchaseOrder-interface.wsdl"/>
<!-- location of WSDL PO interface from Listing-1-->
<!-- wsdl:binding states a serialisation protocol for this service -->
<!-- type attribute must match name of portType element in Listing-1-->
<wsdl:binding name="PurchaseOrderSOAPBinding" Listing 2:
type="tns:PurchaseOrderPortType">
Example of WSDL
<!-- leverage off soapbind:binding synchronous style --> Implementation
<soapbind:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http/"/>
<!-- furthur specify that the messages in the wsdl:operation use SOAP -->
<wsdl:input> map the abstract
<soapbind:body use="literal" input & output messages
namespace="http://supply.com/PurchaseService/wsdl"/> to these concrete messages
</wsdl:input>
<wsdl:output>
<soapbind:body use=“literal"
namespace="http://supply.com/ PurchaseService/wsdl"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
Service name
<wsdl:service name=“PurchaseOrderService">
<wsdl:port name=“PurchaseOrderPort" binding="tns:PurchaseOrderSOAPBinding">
<!-- give the binding a network endpoint address or URI of service --> Network address of service
<soapbind:address location="http://supply.com:8080/PurchaseOrderService"/>
</wsdl:port> 46
</wsdl:service>
</wsdl:definitions>
46
47
What is SOAP?
The standard messaging protocol used by Web services
Primarily for inter-application communication (‘server’ to ‘server’)
Use an XML-based scheme for encoding message (request and response) data
Typically uses HTTP as a means for transport
SOAP-based SOAP-based
middleware middleware
SOAP messages
exchanged on top of,
HTTP, SMTP, JMS or
other transport
48
49
firewall
Distributed messaging
using SOAP
50
50
SOAP messages
<Envelope>
<Envelope>
SOAP is based on message exchanges.
Messages are seen as envelopes where the 0..1 1
application encloses the data to be sent. <Header> <Body>
<Header> <Body>
A SOAP message consists of an <Envelope>
element containing an optional <Header> and a 1..* 1..*
mandatory <Body> element. <Header <Body
<Header <Body
block> entry>
The contents of these elements are application block> entry>
body entry
51
51
GetProductPrice(“450R6OP”); 52
52
<env:Envelope
xmlns:SOAP=“http://www.w3.org/2003/05/soap-envelope”
xmlns:m="http://www.plastics_supply.com/product-prices">
<env:Header>
<--! – Optional context information -->
</env:Header>
<env:Body>
<m:GetProductPriceResponse>
<m:product-price> 134.32 </m:product-price>
</m:GetProductPriceResponse>
</env:Body>
</env:Envelope>
134.32 53
53
54
54
Code to WSDL
55
55
Design tool to
WSDL
56
56
Content
57
57
58
Client-server architecture
Application state is driven by the client’s updating resources
across the resource network using links provided by the server(s)
“Hypermedia is the engine of state”
59
60
60
61
61
62
REST Example
Step 1 : Client asks for a list of parts
63
REST Example
Step 2. Given the part number ….
64
REST example
Placing an order (i.e. creating a new order resource)
65
REST example
Updating a resource
66
67
67
WS* vs RESTful?
WS* RESTful
Easy to understand approach Complex Simpler
Easy to implement Depends... Depends...
Interface definition Specific Generic
Interface Contracts Yes - WSDL Not yet (WADL?)
Specific to the Web No Yes
Implementation of SOA Yes Not really
Scalable Hmmm.... Yes
Addresses enterprise concerns (e.g. Yes Not directly
transactions, end-end security)
Orientation Method Resource
68
68
Content
69
69
Microservices
An architectural approach - Some perspectives
A type of SOA
Functional perspective
- Business functionality/capability oriented partition
Modular
Small (capability) & light-weight (technology: REST)
Self-contained & deployable
Oriented towards development, delivery & deployment
Scalable
Granularity vs Complexity …
70
70
71
71
72
72