66
Review: Development with and without reuse Problem and requirements: hungry person wants pizza. Solutions ?

Review: Development with and without reuse Problem and requirements: hungry person wants pizza. Solutions ?

Embed Size (px)

Citation preview

Review: Development with and without reuse

Problem and requirements: hungry person wants pizza.

Solutions ?

Review: Development with and without reuse

Problem and requirements: hungry person wants pizza

Solution 1:Prepare dough (mix and knead flour, yeast, salt and water)Let dough riseFlatten dough, shapeMake sauce (peel and chop tomatoes, mix with pepper, herbs)Put sauce on doughPut topping (ham, cheese) BakeEat

Do everything from scratch:Advantages: no limitations on design

Disadvantages: need skills, time, resources

Review: Development with and without reuse

Problem and requirements: hungry person wants pizza

Solution 2:Buy pizza doughBuy ketchupPut ketchup on doughPut toppingBakeEat

Build with COTS:Advantages: need less skills, need less timeDisadvantages: design limited by available

components. Possible incompatibilities. Need resources

Review: Development with and without reuse

Problem and requirements: hungry person wants pizza

Solution 3:Phone Pizza ShopWait for deliveryEat

(Re)use services:Advantages: no baking skills and time, no

resources needed Disadvantages: depends on availability of

pizza shops; it buys only a one-time solution

Review: What are the “Software Entities” to compose and reuse?

• Functions

• Modules

• Objects

• Components

• Services

• …2010

2000

1990

1980

1970

1960

1968: Douglas McIlroy: “Mass Produced Software Components”

1998: Clemens Szyperski: “Component Software – Beyond Object Oriented Programming”

Review: Objects-Components-Services

Entities for Reuse and Composition•Abstraction

•Encapsulation

Objects Components Services•Location: same process

•Inheritance

•Polymorphism

•Location: different processes, same environment

•Usually some runtime infrastructure needed

•Provided and required interfaces

•Location: different environments

•More emphasis on interface/contract/service agreement

•Mechanisms for dynamic discovery

•Dynamically composable

Reuse and Composition in Service Computing

Main Bibliography:Chap. 31, SommervilleAdditional Reading:Thomas Erl: SOA: Concepts, Technology and Design

Outline• Concepts: Services, SOA, WebServices

• Services as reusable components

• Service engineering

• Software development with services

What is a 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.

Service-oriented architectures

• A means of developing distributed systems where the components are stand-alone services

• Services may execute on different computers from different service providers

• Standard protocols have been developed to support service communication and information exchange

• Services are platform and implementation-language independent

• Registries enable the discovery of services

Characteristics of Primitive SOA

Serviceregistry

Servicerequestor

Serviceprovider

Publish

Bind

Find

service

Benefits of services

• 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.

Contemporary SOA• Complex applications require more than the provider-requester-

registry triangle

• Activities: a task performed by a set of interacting services• Coordination: complex activities need context data and the

subsequent need for this data to be managed at runtime• Atomic transactions: being able to guarantee an outcome of an

activity• Business activities: manage complex long-running activities that can

vary in scope and the participating services• Orchestration: an organization-speciffic business workflow; an

organization owns and controlls logic behind composition• Choreography: there is no single owner of the collaboration logic

Benefits of SOA

• Services can be provided locally or outsourced to external providers

• Services are language-independent

• Investment in legacy systems can be preserved

• Inter-organisational computing is facilitated through simplified information exchange

Services standards

• Services are based on agreed standards so can be provided on any platform and written in any programming language.

• Web services: one kind of services

• Thomas Erl: common misperceptions about SOA:– “An application that uses web services is service-oriented”

– “SOA is just a marketing term used to re-brand web services”

Web Services Definition by W34C

• A Web service is a software application

• identified by an URI,

• whose interfaces and bindings are capable of being defined, described and discovered by XML artifacts and

• supports direct interactions with other software applications

• using XML based messages

• via internet-based protocols

Web Services

• The Web Services initiative has been driven by standards from its beginning (vs Components where standardisation has been tried later and several different standards=component models are in use)

• Key standards– XML – Extensible Markup Language– SOAP - Simple Object Access Protocol;– WSDL - Web Services Description Language;– UDDI - Universal Description, Discovery and

Integration.

SOA based on Web Services

Serviceregistry

Servicerequestor

Serviceprovider

Service

Find Publish

Bind (SOAP)(WSDL)

(UDDI)

Key standards

• SOAP– A message layout standard that supports service communication

– Defines a uniform way of passing XML-encoded data

– Defines a way to bind HTTP as the underlying communication protocol

• 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

More Web Services 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, ....)

Standards organizations that contribute to SOA / WS

• The World Wide Web Consortium W3C:– Goal: to further the evolution of the web, by providing

fundamental standards that improve online business and information sharing

– XML, XMLSchema, WSDL, SOAP

• Organisation for the Advancement of Structured Information Standards OASIS– Goal: to promote online trade and commerce via specialized

Web services standards– UDDI, WS-BPEL, WS-Security

• Major vendors that contribute to SOA– Microsoft, IBM, BEA Systems, Sun, Oracle, Tibco, Hewlett-

Packard, Canon

Distributed Object Computing vs. SOA / WS

IP

TCP

IIOP

Object Request Broker

IDL

HTTP

SOAP

WSDL

Web Server/ Application Server

Programming languages

Programming languages

Distributed Object Computing vs. SOA / WS

• Within enterprise

• Tied to a set of programming languages

• Procedural

• Usually bound to a particular transport

• Efficient processing

• Between enterprises

• Program language independent

• Message-driven

• Easy bound to different transports

• Lower effficiency

Web Application vs. SOA / WS

• User-to-program interaction

• Static integration of components

• Monolithic service

• Program-to-program interaction

• Possibility of dynamic integration of components

• Possibility of service aggregation

Outline• Concepts: Services, SOA, WebServices

• Services as reusable componentsServices as reusable components

• Service engineering

• Software development with services

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

• Abstraction and encapsulation: WSDL service description (‘provides’ interface) and service implementation– In order to use a service, a client needs only the WSDL

• A critical distinction between a service and a component as defined in CBSE is that services are independent– Services do not have a ‘requires’ interface

– Services rely on message-based communication with messages expressed in XML (not on method calls)

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.

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>

Message-based communication

Web Service Description Language (WSDL)

• An Interface Definition Language (IDL)• An IDL is needed when languages differ• Other example IDL’s:– Corba IDL (Object-oriented syntax)– OSF’s DCE (C like syntax)– DCOM IDL based on OSF’s DCE and used

by Microsoft’s DCOM– Sun XDR (An IDL for RPC)

Web service description language

• The service interface is defined in a service description expressed in WSDL. 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 onto a concrete set of protocols– Where the service is located. This is usually expressed as a URI

(Universal Resource Identifier)

Structure of a WSDL specification

Intro

Abstract interface

Concreteimplementation

WSDL service definition

XML namespace declarations

Type declarationsInterface declarationsMessage declarations

Binding declarationsEndpoint declarations

Main elements of a WSDL document

• XML elements in its description:– Abstract interface:

• <portType> (renamed <interface> in WSDL 2.0)

• <operation>

• <message>

• <types>

– Concrete implementation:• <binding>

• <port> (renamed <endpoint> in WSDL 2.0)

• <service>

WSDL document structure<definitions>

<portType>

</portType>

<message>

</message>

<types>

</types>

<binding>

</binding>

</definitions>

<portType> Element• This is probably the most important element• Describes the web service

– Operations that can be performed– Messages that are involved– Comparable to a function/method library in a programming language– A port is defined by associating a network address with a reusable binding

<message> Element

• Defines the data elements of an operation

• Each message can have one or more parts

• Each part is comparable to a function/method call in a programming language

Simplified Example

<message name="getTermRequest">  <part name="term" type="xs:string"/></message>

<message name="getTermResponse">  <part name="value" type="xs:string"/></message>

<portType name="glossaryTerms">  <operation name="getTerm">    <input message="getTermRequest"/>    <output message="getTermResponse"/>  </operation></portType>

Types of operations

– One-way• Can receive a message, but will not return a message

• Example use: receiving request to insert a new value in a database

– Request-response• Can receive a request and will return a response

• Example use: receiving a request for a value from a database and sending it back in a response

– Solicit-response• Can send a request and will wait for a response

• Example use: requesting a value from a database and having it sent back in the response

– Notification• Can send a message, but will not wait for a response

• Example use: inserting a new value in a database

Example of one-way operation

<message name="newTermValues">  <part name="term" type="xs:string"/>  <part name="value" type="xs:string"/></message>

<portType name="glossaryTerms">  <operation name="setTerm">    <input name="newTerm" message="newTermValues"/>  </operation></portType >

<binding> Element

• One binding represents one possible transport technology the service can use to communicate

• A binding can apply to an entire interface or just a specific operation

• Has two attributes:– Name – Can be set to any value, which represents the name of the

binding

– Type – Points to the port (interface) for the binding

• When using SOAP, a <soap:binding> sub-element is used to set the style and transport values with elements:– Style – with value of either “rpc” or “document”

– Transport – defines the SOAP protocol to use

(like HTTP)

SOAP binding example

<portType name="glossaryTerms">  <operation name="getTerm">    <input message="getTermRequest"/>    <output message="getTermResponse"/>  </operation></portType>

<binding type="glossaryTerms" name="b1">   <soap:binding style="document"   transport="http://schemas.xmlsoap.org/soap/http" />     </operation></binding>

<port> (<endpoint>) Element

• A <port> or <endpoint> represents the physical address at which a service (interface) can be accessed with a specific protocol

• A <service> groups a set of related endpoints

Endpoint example

<service name=“GlossaryTermsService”> <port name=“GlossaryTermsSoap1” binding=“b1”> <soap:address location=“http://myserver.com/WebServices/GlossaryTerms1.asmx ” /> </port> </service>

IDL model for Web Services

• WSDL acts as an IDL for Web Services distributed programming model

• Definitions are processed by an IDL compiler to generate:– stubs for clients which look like local function calls– Dispatch routines for the server that invoke the developer’s code

• Tools can generate WSDL descriptions from implementations

• Tools can generate implementation stubs from WSDL• Technology examples:

– Java: Axis: wsdl2java, java2wsdl– .NET: wsdl.exe

How Clients Use Services

• In order to use a service, a Client program needs only its WSDL (contains abstract interface description and URI of service endpoint)

• The client program can access the service in many ways:– Using Dynamic Invocation Interface ( DII)

– Using generated Stubs from Service WSDL description

– Using Dynamic Proxy

Client using DII

import javax.xml.rpc.Call;

import javax.xml.rpc.Service;

import javax.xml.namespace.QName;

String endpoint = "http://localhost:8080/axis/AddFunction.jws";

Service service = new Service();

Call call = (Call) service.createCall();

call.setOperationName(new QName(endpoint, "addInt"));

call.setTargetEndpointAddress( new java.net.URL(endpoint) );

Integer ret = (Integer)call.invoke(new Object[]{new Integer(5), new Integer(6)});

Client using Generated Stubs

import localhost.*;

AddFunctionService afs = new AddFunctionServiceLocator();

AddFunction af = afs.getAddFunction();

System.out.println("addInt(5, 3) = " + af.addInt(5, 3));

Generate the stubs with wsdl2java

Client using Dynamic Proxy

import javax.xml.namespace.QName;

import javax.xml.rpc.*;

String wsdlUrl = "http://localhost:8080/axis/AddFunction.jws?wsdl";

String nameSpaceUri = "http://localhost:8080/axis/AddFunction.jws";

String serviceName = "AddFunctionService";

String portName = "AddFunction";

ServiceFactory serviceFactory = ServiceFactory.newInstance();

Service afs = serviceFactory.createService(new java.net.URL(wsdlUrl),

new QName(nameSpaceUri, serviceName));

AddFunctionServiceIntf afsIntf = (AddFunctionServiceIntf)afs.getPort(

new QName(nameSpaceUri, portName), AddFunctionServiceIntf.class);

System.out.println("addInt(5, 3) = " + afsIntf.addInt(5, 3));

Outline• Concepts: Services, SOA, WebServices

• Services as reusable components

• Service engineeringService engineering

• Software development with services

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

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

The service engineering process

Service designService

candidateidentification

Serviceimplementationand deployment

Servicerequirements

Service interfacespecification

Validated anddeployed service

Service candidate identification

• Three fundamental types of service– Utility services that implement general functionality used by

different business processes• Example: currency converter

– Business services that are associated with a specific business function • Example: in a university, student registration

– Coordination services that support composite processes involving different actors and activities• Example: an ordering service that allows orders to be placed with

suppliers, goods accepted and payments made

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

Task-oriented service: associated with some activityEntity-oriented service: assocoated with some business entity

Service identification

• Goal of service identification: identify services that are logically coherent, independent and reusable.

• Where to start: looking at business entities and business activities

• 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?

Example: Catalogue services

• Created by a supplier to show which good 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

Example: Catalogue - Non-functional requirements

• Access shall be restricted to employees of accredited organisations

• Prices and configurations offered to each organisation shall be confidential

• The catalogue shall be available from 0700 to 1100

• The catalogue shall be able to process up to 10 requests per second

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.

• Service state information may have to be included in messages

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

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 searches 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.

Example - 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

Service implementation and deployment

• Programming services 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:– installing it on a web server. Current servers provide support for service

installation

– publicising the service (using UDDI)

UDDI

• Universal Description, Discovery and Integration• Registry for Web services• Similar to CORBA’s Naming Service• Has a Web Services API for publishing and discovering

the existence of Web services• A registry where you find a Web service and its

description (WSDL)– Search by business– Search by service type

• UDDI registries can be:– Public– Private

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

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.

Outline• Concepts: Services, SOA, WebServices

• Services as reusable components

• Service engineering

• Software development with services => NEXT