service-oriented softwarekremer.cpsc.ucalgary.ca/courses/seng403/w2012/papers/7 service... ·...

50
Service-Oriented Software Michael Godwin Ben Miller Neil Wilson Lingiie Ye

Upload: donhi

Post on 18-May-2018

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Service-Oriented Software

Michael Godwin Ben Miller

Neil Wilson Lingiie Ye

Page 2: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Introduction

•  Background of Service-Oriented Software

•  Service-Oriented Architecture (SOA)

• Where SOA is used

•  How you can create your own service

Page 3: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

What is SOA? •  The future!! (arguably)

• Mash-up of multiple services in one site

•  Services are autonomous

•  Usually used in web-based software

•  Designed to meet users ever-changing needs

Page 4: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Advantages •  Simplifies understanding the software

•  Allows for simplified modifications •  Adding/removing services is easy •  Debugging services is easy

•  Centralized data

•  Versatility

•  High fault tolerance

Page 5: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Disadvantages

• Not suited for applications that require a lot of data transfer

•  Requires complex management infrastructure

•  Difficult to initially learn to create •  Consumes a lot of CPU time

Page 6: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOA •  A Service Oriented Architecture aims create and use

small pieces of software to accomplish a greater goal

•  Services are the small pieces of software used as building blocks

•  A client is any piece of software that is written to use a service for some functionality

•  A registry is a server that hosts information about web services so that clients can find web services

Page 7: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOA

Page 8: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Services •  Individual software systems that can be

queried by other software

•  Implementation has two parts:

•  The logic of the services

•  The service messaging system

•  Important to consider how a service will message a client

Page 9: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Service Design Principles

•  Services should be a small unit of software with a distinct goal or purpose

•  Allows for easier reuse

•  If you want your service to accomplish some significant task, consider writing more than one service

•  Decouple the Messaging and the logic as much as possible

•  If you change your service, you don’t want to break all of the clients that are designed to access your service

•  Implantation Details and Hosting Platform aren't important

Page 10: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Communication •  Communication is huge in SOA

• We have all of these services, how do they talk to clients?

•  Two different things need to be established:

•  How can we expose a services interface to clients in a convenient manner?

•  What is the format of messages sent to and from services?

Page 11: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Web Services Description Language (WSDL)

•  XML Language to describe a service’s interface

•  Standard document format, maintained by W3C

•  Client reads the WSDL file, and discovers:

•  What kind of requests can be sent to the service, and what the parameters and return type will be

•  Think function prototypes

•  What kind of messaging protocol must be used to send these requests

Page 12: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

WSDL

Page 13: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP Protocol •  An XML message protocol

•  Created by Microsoft in 1998

•  Standardize the messages sent between Client and Service

•  Can be used over any transfer protocol (HTTP, SMTP, TCP)

Page 14: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP Protocol POST /InStock HTTP/1.1���

Host: www.example.org���Content-Type: application/soap+xml; charset=utf-8���Content-Length: nnn������< ?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:Body xmlns:m="http://www.example.org/stock">��� <m:GetStockPrice>��� <m:StockName>IBM</m:StockName>��� </m:GetStockPrice>��� </soap:Body>������< /soap:Envelope>

Page 15: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

RESTful Web Services •  A design philosophy for creating web services

•  New Idea

•  RESTful web services have only been around since mid 2000’s

•  REST =

•  REpresentational

•  State

•  Transfer

•  REST was defined by Roy Fielding, Creator of HTTP, in 2000.

Page 16: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

RESTful Web Services •  Key RESTful Concepts:

•  Separate the concerns of the client and the service

•  System should be stateless. No client information needs to be stored by the service

•  Must implement a uniform interface between client and server, usually uses HTTP’s methods (GET, POST, PUT, DELETE)

Page 17: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

RESTful Web Services •  How does this actually work?

•  The service has some resources or data that it would like to expose to client systems

•  The web server is set up to give URIs to each of these resources or data

•  Eg: http://www.myservice.org/discussion/topics/1

•  A client may now retrieve that piece of information from the service by sending an HTTP GET request to that URI

•  The service sends back a very simple XML or JSON file containing only the information asked for

Page 18: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP vs. RESTful Web Services

•  Current debate in development community

•  If im making a web service, should I use SOAP, or make it a RESTful web service?

Page 19: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP vs. RESTful Web Services

•  RESTful Advantages:

•  Lightweight: No need for extensive XML Markup. Messages are much smaller.

•  Can return anything as a response message, so things like JSON can be used

•  No extensive toolkits are required to create

Page 20: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP vs. RESTful Web Services •  SOAP Advantages:

•  Language, Platform and Transport independent

•  Built in error handling

•  Strong typing guarantees type security

•  Built to handle distributed computing enviroments

•  Robust tool support

•  Various security extensions have been developed for SOAP

Page 21: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

SOAP vs. RESTful Bottom Line •  RESTful Web Services are easy to get off the ground

and provide most of the functionality of SOAP

•  If you can use RESTful, you probably should

•  SOAP still has uses

•  Non web based SOA systems

•  Distributed computing enviroments

•  Some critical security extensions

Page 22: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

External Facing Services

•  Integration •  Available through public API

Page 23: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Google Translate API

GET https://www.googleapis.com/language/translate/v2?key=&source=en&target=de&q=Hello%20world

200 OK { "data": { "translations": [ { "translatedText": "Hallo Welt" } ] } }

Page 24: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

The Cloud •  Storage

•  Computing (SaaS)

•  Servers

Page 25: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Case Study: eBay 2 500 000 000 Hits on a busy

day

2 000 000 000 000 000 bytes of data

6 000 000 lines of code

100 000 new lines of code every two weeks

30 000 software builds per week

Internal Facing Services

Page 26: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Case Study: eBay •  Helped to solve the complexity

issues •  Helped to solve many other

technical problems such as interoperation between C++ and Java

•  Greatest benefit was in management

Page 27: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Case Study: eBay •  Business Agility

o  Produced new features faster

o  Quicker response to change o  Easier integration with partners

•  Innovation o  Enabled internal and external innovation

•  Operational Excellence o  Reduced cost for new features o  Efficient resource utilization o  Reduced cost of failure

Benefits

Page 28: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Case Study: eBay Challenges

•  Learning Curve •  Governance •  Migration •  Deployment •  Metrics •  Integration Testing

Page 29: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Tech Talk •  Service is big on sharing, and sharing requires

adherence to standards.

•  SOA grants freedom to choose language.

•  All major languages have SOA libraries. •  Java SOAP: JAX-WS, JAX-PRC, Axis •  Java REST: RESTlet, Jersey •  C# SOAP: Web Reference, Service References •  C# REST: OpenRasta •  Python SOAP: SUDS, soaplib, pysimplesoap •  Python REST: built-in web libraries suffice (guide)

29

Page 30: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Tech Talk

Die-hard Fundamentalist

DIY Vimer?

30

Page 31: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Tech Talk • Many IDE have SOA development tools & plugins

•  Technologies change often, search for the latest

•  To get a quick start, finding a toolkit that has up-to-date documentation is important.

•  For this quick demo, I decided to use •  Java •  SOAP •  Oracle JDeveloper with JAX-WS

31

Page 32: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Registry •  There are very few open registry for free-lance

developers to publish their services.

•  Large-corporations often host their own closed service registries.

•  Maybe open to the public to consume

•  But do not allow public publishing service

•  JDeveloper integrated WebLogic Server to host & test services locally.

32

Page 33: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

ESB • ESB - Enterprise service bus

• The prime duties of an ESB are:

•  Monitor and control routing of message exchange between services

•  Resolve contention between communicating service components

•  Control deployment and versioning of services

• Popular ESB: webMethods, Mule

33

Page 34: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Publishing •  Since input parameters and return value will

be serialized into XML, their type must be •  Primitive types: int, float, double

•  Primitive type Wrappers: Integer, Double

•  Strings

•  A Java bean with a zero-argument constructor, with a pair of "get" and "set" methods for each property to be exposed.

•  Array of those types

34

Page 35: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Publishing •  Bottom-up

•  Work with existing software, turn into services

•  Some say it’s better for updating legacy systems

•  Top-down •  Design and create interfaces first, then implement

•  Some say it promotes more reuse, but may require organization-wide change.

• On-going debate

35

Page 36: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Bottom-up Code before

36

Page 37: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Bottom-up Code after

37

Page 38: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Testing with HTTP analyzer

38

Bottom-up

Page 39: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Testing with HTTP analyzer

39

Page 40: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Testing with HTTP analyzer

40

Page 41: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Testing with HTTP analyzer

41

Flow of Data

Page 42: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Top-down From WSDL, use wizard to generate code stub

42

Page 43: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Top-down From WSDL, use wizard to generate code stub

43

Page 44: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Top-down Implement method

44

Page 45: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Consuming •  Discovering and binding of services

•  Technologies: UDDI, ebXML, WSIL

•  Facilitate discovery

•  Automated, and dynamic by using simple API

•  Example: JAXR - Java API for XML Registries

•  Tools generate local wrapper method/functions for the service

45

Page 46: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Consuming Wizard to generate local wrapper methods

46

Page 47: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Consuming Specify WSDL location – step may be automated

47

Page 48: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Generated code

Consuming

48

Page 49: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Consuming Using service by calling wrapper method

49

Page 50: Service-Oriented Softwarekremer.cpsc.ucalgary.ca/courses/seng403/W2012/papers/7 Service... · Introduction! • Background of Service-Oriented Software! • Service-Oriented Architecture

Key Points to Remember •  Comm. Standards are important. (SOAP, REST)

•  Lots of technologies to choose from. There will be libraries to help you do SOA.

•  Provider vs. Registry vs. Consumer

•  Only use parameters that can be serialized to XML when creating services

•  Top-down vs. Bottom-up approach •  Service discovery & binding. Local wrapper.

50