©ian sommerville 2006msc module: advanced software engineering slide 1 service-centric software...
TRANSCRIPT
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 1
Service-centric Software Engineering
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 2
Objectives
To introduce the idea of service-oriented architectures To explain the notion of a reusable service, based on web
service standards, that provides a mechanism for inter-organisational computing;
To describe the service engineering process that is intended to produce reusable web services;
To introduce service composition as a means of application development;
To show how business process models may be used as a basis for the design of service-oriented systems.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 3
Topics covered
Service-oriented architectures Services as reusable components Service engineering Software development with services
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 4
Service-oriented architectures
Based around the notion of externally provided services (web services).
A web service is a standard approach to making a reusable component available and accessible across the web• A tax filing service could provide support for users to fill
in their tax forms and submit these to the tax authorities.
Services may execute on different computers from different service providers.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 5
A generic service
An act or performance offered by one party to another. Although the process may be tied to a physical product, the performance is essentially intangible and does not normally result in ownership of any of the factors of production.
Service provision is therefore independent of the application using the service.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 6
Web services
Serviceregistry
Servicerequestor
Serviceprovider
Publish
Bind
Find
service
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 7
Service roles
Service registry• Provides details of the range of services that are
available (possibly from different providers) Service provider
• Hosts a service that can be accessed and used by external clients
Service requestor• Seeks a service to be incorporated into an application
or a business process
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 8
Services and distributed objects
Provider independence. Public advertising of service availability. Potentially, run-time service binding. Opportunistic construction of new services through
composition. Pay for use of services. Smaller, more compact applications. Reactive and adaptive applications.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 9
Services scenario
An in-car information system provides drivers with information on weather, road traffic conditions, local information etc. This is linked to car radio so that information is delivered as a signal on a specific radio channel.
The car is equipped with GPS receiver to discover its position and, based on that position, the system accesses a range of information services. Information may be delivered in the driver’s specified language.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 10
Automotive system
User interface
Locator
Discovers carposition
Weatherinfo
Receives requestfrom user
Receiver
Receivesinformation stream
from services
Transmitter
Sends position andinformation request
to services
Radio
Translates digitalinfo stream toradio signal
In-car software system
Mobile Info Service
Facilitiesinfo
Translator
Roadlocator
Trafficinfo
Collates information
Road traffic info
commandgps coord
gpscoord gps coordgps coord
Languageinfo
Infostream
Service discovery
Finds availableservices
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 11
Hybrid system
The in-car system is an example of a hybrid system where local computation does not use a web service based approach (Too much computational and communication overhead)
However, features that rely on external information or which require more processing than can be provided on-board (e,g, translation) are accessed as services.
Mobility means binding to different services depending on location.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 12
Benefits of SOA
Services can be provided locally or outsourced to external providers
Services are language-independent Investment in legacy systems can be preserved Applications can be adaptive, binding to different
services as availability and capability changes Inter-organisational computing is facilitated through
simplified information exchange
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 13
Web service standards
Transport (HTTP, HTTPS, SMTP, ...)
Messaging (SOAP)
Service definition (UDDI, WSDL)
Process (WS-BPEL)
Support (WS-Security , WS-Addressing, ...)
XML technologies (XML, XSD, XSL T, ....)
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 14
Key standards
SOAP• A message exchange standard that supports service
communication WSDL (Web Service Definition Language)
• This standard allows a service interface and its bindings to be defined
UDDI• Defines the components of a service specification that may
be used to discover the existence of a service WS-BPEL
• A standard for workflow languages used to define service composition
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 15
Other standards
A standards body exists (OASIS) to ratify service standards but it is not completely effective
There are a huge number of proposed standards to support other aspects of SOA (e.g. security, dependability, QoS, etc.) but few of these standards have been agreed or accepted by the major vendors.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 16
Service-oriented software engineering
Existing approaches to software engineering have to evolve to reflect the service-oriented approach to software development• Service engineering. The development of dependable,
reusable services• Software development for reuse
• Software development with services. The development of dependable software where services are the fundamental components• Software development with reuse
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 17
Services as reusable components
A service can be defined as:• A loosely-coupled, reusable software component that encapsulates
discrete functionality which may be distributed and programmatically accessed. A web service is a service that is accessed using standard Internet and XML-based protocols
A critical distinction between a service and a component as defined in CBSE is that services are independent• Services rely on message-based communication with messages
expressed in XML• Services are stateless ie they do not maintain information from one
invocation to another
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 18
RPC vs message based interaction
Component-based system generally use a style of interaction which is based on a remote procedure or method call i.e. the remote component is called as if it was local.
Middleware is used to manage this interaction. Services use a different approach based on
message passing where all information about the service required is bundled into a single message
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 19
Synchronous interaction
Tomato soup please
Waiter Diner
What would you like?
And to follow?
Fillet steak
How would you like it cooked?
Rare please
With salad or french fries?
Salad please
ETC.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 20
An order as an XML message
<starter> <dish name = “soup” type = “tomato” /> <dish name = “soup” type = “fish” /> <dish name = “pigeon salad” /> </starter> <main course> <dish name = “steak” type = “sirloin” cooking = “medium” /> <dish name = “steak” type = “fillet” cooking = “rare” /> <dish name = “sea bass”> </main> <accompaniment> <dish name = “french fries” portions = “2” /> <dish name = “salad” portions = “1” /> </accompaniment>
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 21
Web service description language
The service interface is defined in a service description expressed in WSDL. This has been agreed as a standard and is generally adopted.
The WSDL specification defines• What operations the service supports and the format of
the messages that are sent and received by the service
• How the service is accessed - that is, the binding maps the abstract interface ontoa concrete set of protocols
• Where the service is located. This is usually expressed as a URI (Universal Resource Identifier)
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 22
Structure of a WSDL specification
Intro
Abstract interface
Concreteimplementation
WSDL service definition
XML namespace declarations
Type declarationsInterface declarationsMessage declarations
Binding declarationsEndpoint declarations
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 23
A WSDL description fragment
Define some of the types used. Assume that the namespace prefixes ‘ws’ refers to the namespace URI for XML schemas and the namespace prefix associated with this definition is weathns. <types> <xs: schema targetNameSpace = “http://.../weathns” xmlns: weathns = “http://…/weathns” > <xs:element name = “PlaceAndDate” type = “pdrec” /> <xs:element name = “MaxMinTemp” type = “mmtrec” /> <xs: element name = “InDataFault” type = “errmess” /> <xs: complexType name = “pdrec” <xs: sequence> <xs:element name = “town” type = “xs:string”/> <xs:element name = “country” type = “xs:string”/> <xs:element name = “day” type = “xs:date” /> </xs:complexType> Definitions of MaxMinType and InDataFault here </schema> </types>
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 24
A WSDL description fragment 2
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 25
Service engineering
The process of developing services for reuse in service-oriented applications
The service has to be designed as a reusable abstraction that can be used in different systems
Involves• Service candidate identification
• Service design
• Service implementation
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 26
The service engineering process
Service designService
candidateidentification
Serviceimplementationand deployment
Servicerequirements
Service interfacespecification
Validated anddeployed service
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 27
Service candidate identification
Three fundamental types of service• Utility services that implement general functionality
used by different business processes
• Business services that are associated with a specific business function e.g., in a university, student registration
• Coordination services that support composite processes such as ordering
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 28
Service classification
Utility Business Co ordination Task Currency
convertor Employee locator
Validate claim form Check credit rating
Process expense claim Pay external supplier
Entity Document style checker Web form to XML converter
Expenses form Student application form
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 29
Service identification
Is the service associated with a single logical entity used in different business processes?
Is the task one that is carried out by different people in the organisation?
Is the service independent? Does the service have to maintain state? Is a database
required? Could the service be used by clients outside the
organisation? Are different users of the service likely to have different non-
functional requirements?
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 30
Catalogue services
Created by a supplier to show which goods can be ordered from them by other companies
Service requirements• Specific version of catalogue should be created for each client• Catalogue shall be downloadable• The specification and prices of up to 6 items may be compared• Browsing and searching facilities shall be provided• A function shall be provided that allows the delivery date for
ordered items to be predicted• Virtual orders shall be supported which reserve the goods for 48
hours to allow a company order to be placed
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 31
Catalogue - Non-functional requirements
Access shall be restricted to employees of accredited organisations
Prices and configurations offered to each organisation shall be confidential• Because different prices may be agreed for different
customers The catalogue shall be available from 0700 to 1100 The catalogue shall be able to process up to 10
requests per second
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 32
Catalogue service operations
Operation Description
MakeCatalogue Creates a version of the cat alogue tailored for a specific customer. Inc ludes an o ptional parameter to create a downloadable PDF version of the catalogue.
Compare Provides a comparison of up to 6 characteristics (e.g. price, dimensions, p rocessor speed, etc .) of up to 4 catalogue it ems for comparison.
Lookup Displays all of the data assoc iated with a specified catalogue item.
Search This operation takes a logical expression and searche s the catalogue according to that expression. It displays a list of all items that match the search expression.
CheckDelivery Returns the predicted delivery date for an item if it is ordered today.
MakeVirtualOrder Reserves the number of items to be ordered by a customer and provides item information for the customer’s own procurement system.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 33
Service interface design
Involves thinking about the operations associated with the service and the messages exchanged
The number of messages exchanged to complete a service request should normally be minimised to reduce the communication overhead.
Service state information may have to be included in messages as services should not maintain state.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 34
Interface design stages
Logical interface design• Starts with the service requirements and defines the
operation names and parameters associated with the service. Exceptions should also be defined
Message design• Design the structure and organisation of the input and
output messages. Notations such as the UML are a more abstract representation than XML
WSDL description• The logical specification is converted to a WSDL
description
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 35
Catalogue interface design
Operation Inputs Outputs Exceptions
MakeCatalogue mcIn Company id PDF-flag
mcOut URL of the catalogue for that company
mcFault Invalid company id
Compare compIn Company id Entry attribute (up to 6) Catalogue number (up to 4)
compOut URL of page showing comparison table
compFault Invalid company id Invalid catalogue number Unknown attr ibute
Lookup lookIn Company id Catalogue number
lookOut URL of page with the item information
lookFault Invalid company id Invalid catalogue number
Search searchIn Company id Search string
searchOut URL of web page with search results
searchFault Invalid company id Badly-formed search string
CheckDelivery gdIn Company id Catalogue number Number of items required
gdOut Catalogue number Expected delivery date
gdFault Invalid company id Invalid catalogue number No availability Zero items requested
PlaceOrder poIn Company id Number of items required Catalogue number
poOut Catalogue number Number of items required Predicted delivery date Unit price estimate Total price estimate
poFault Invalid company id Invalid catalogue number Zero items requested
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 36
Message structure definition
This has to be (ultimately) expressed in XML but I think it is easier to think about and express this graphically (using a notation such as the UML) and then translate this to XML.
Rules about the information in the message may be added using UML comments and OCL (the object constraint language)
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 37
Input and output message structure
gdIn
cID: stringcatNum: stringnumItems: integer
size (cID) = 6size (catNum) = 10numItems > 0
gdOut
catNum: stringdelivDate: date
size (catNum) = 10delivDate > Today
gdFault
errCode: integer
Invalid company iderrCode=1
Invalid catalogue numbererrCode = 2
No availabilityerrCode = 3
Zero items requestederrCode = 4
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 38
Service implementation and deployment
Services are programmed using a standard programming language or a workflow language
Services then have to be tested by creating input messages and checking that the output messages produced are as expected
Deployment involves publicising the service using UDDI or in some other way and installing it on a web server.
Current servers provide support for service installation
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 39
A UDDI description
Details of the business providing the service An informal description of the functionality provided by the
service Information where to find the service’s WSDL specification Subscription information that allows users to register for
service updates UDDI is very limited in the information that it can maintain
about a service. Service functionality is generally expressed in one or two sentences of natural language.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 40
Legacy system services
An important application of services is to provide access to functionality embedded in legacy systems
Legacy systems offer extensive functionality and this can reduce the cost of service implementation
External applications can access this functionality through the service interfaces
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 41
Maintenance support system
A large company maintains an inventory of equipment and an associated maintenance database. This keeps track of maintenance requests for equipment, when maintenance was carried out, etc. and generates daily job lists, costs of maintainance, etc.
New features are to add real-time access to the system from portable terminals
This cannot be done by simply enhancing the existing system
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 42
Legacy system access
Maintenance supportlegacy application
«service»Maintenance
getJobsuspendJobcompleteJob
«service»Facilities
addEquipmentdeleteEquipmenteditEquipment
«service»Logging
addRequestdeleteRequestqueryRequests
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 43
Maintenance services
Maintenance service• Manages maintainance jobs
Facilities service• Manages the addition and deletion of equipment from
the database Logging service
• Manages maintenance requests New system is built on top of these services
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 44
Software development with services
Existing services are composed and configured to create new composite services and applications
The basis for service composition is often a workflow• Workflows are logical sequences of activities that,
together, model a coherent business process
• For example, provide a travel reservation services which allows flights, car hire and hotel bookings to be coordinated
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 45
Vacation package workflow
Bookflights
Bookhotel
Arrangecar or taxi
Browseattractions
Bookattractions
Arrival/departuredates/times Hotel location
Dates/preferences
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 46
Construction by composition
Formulateoutline
workflow
Discoverservices
Workflowdesign
Service list Servicespecifications
Workflowdesign
Selectservices
Refineworkflow
Createworkflowprogram
Executableworkflow
Testservice
Deployableservice
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 47
Hotel booking workflow
Hotels.GetRequirements
Customer
Hotels.CheckAvailability
Hotels.NoAvailability
Hotels.ReserveRooms
Hotels.ConfirmReservation
Retry
Cancel
Rooms OK
No rooms
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 48
Workflow design and implementation
WS-BPEL is an XML-standard for workflow specification. However, WS-BPEL descriptions are long and unreadable.
Graphical workflow notations, such as BPMN, are more readable and WS-BPEL can be generated from them.
In inter-organisational systems, separate workflows are created for each organisation and linked through message exchange.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 49
Interacting workflows
Requestprocessor
Setup jobparameters
Downloaddata
Startcomputation
Storeresults
Reportcompletion
Restart
Fail
CheckAvailability
Allocateresources
Initialise Compute
Returnresults
OK
No processor
OK
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 50
Service testing
Testing is intended to find defects and demonstrate that a system meets its functional and non-functional requirements.
Service testing is difficult as (external) services are ‘black-boxes’. Testing techniques that rely on the program source code cannot be used.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 51
Service testing problems
External services may be modified by the service provider thus invalidating tests which have been completed.
Dynamic binding means that the service used in an application may vary - the application tests are not, therefore, reliable.
The non-functional behaviour of the service is unpredictable because it depends on load.
If services have to be paid for as used, testing a service may be expensive.
It may be difficult to invoke compensating actions in external services as these may rely on the failure of other services which cannot be simulated.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 52
Service modification
A service is under the control of the service provider who may change this as they wish
While you would expect the interface to be maintained, the non-functional characteristics of a service may change thus changing the non-functional characteristics of an application using the service
If the service behaviour changes, how can a service user get to the previous version of the service.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 53
Dynamic binding
Different versions of the ‘same’ service which an application may bind to may:• Have different non-functional characteristics
• Have different bugs Binding to different services may therefore have
different results A ‘successful’ test may not be replicatable as the
service used may disappear
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 54
Behaviour under load
If a service is tested at some time A, it may perform satisfactorily because few other users are using it at that time
At some later time, when it is more heavily loaded, its behaviour may not be acceptable
The load behaviour of the service is outside the control of the service client
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 55
Service payment
If a service provider expects to be paid for a service then:• There may be a significant cost in testing a service and
that cost may not be justifiable if the tests suggest that the service does not meet the requirements
• If the service provider allows free access for testing, they may limit this so that the load on the service does not degrade the performance for other users
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 56
Compensating actions
Compensating actions occur when there is a need to reverse some previous action e.g. cancel a flight booking because a hotel is unavailable
However, the conditions where these actions occur is not under the control of the application - therefore, it may be difficult to simulate failure in other to ensure that the compensating actions are invoked.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 57
Key points
Service-oriented software engineering is based on the notion that programs can be constructed by composing independent services which encapsulate reusable functionality.
Service interfaces are defined in WSDL. A WSDL specification includes a definition of the interface types and operations, the binding protocol used by the service and the service location.
Services may be classified as utility services, business services or coordination services.
The service engineering process involves identifying candidate services for implementation, defining the service interface and implementing, testing and deploying the service.
©Ian Sommerville 2006 MSc module: Advanced Software Engineering Slide 58
Key points
Service interfaces may be defined for legacy software systems which may then be reused in other applications.
Software development using services involves creating programs by composing and configuring services to create new composite services.
Business process models define the activities and information exchange in business processes. Activities in the business process may be implemented by services so the business process model represents a service composition.
Techniques of software testing based on source-code analysis cannot be used in service-oriented systems that rely on externally provided services.