service-oriented programming introduction to service- oriented programming 1

65
Service- Oriented Programming Introduction to service-oriented programming 1

Upload: enrique-blackmer

Post on 14-Dec-2015

273 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Service-Oriented Programming Introduction to service- oriented programming 1

1

Service-Oriented ProgrammingIntroduction to service-oriented programming

Page 2: Service-Oriented Programming Introduction to service- oriented programming 1

2

Aims You should able to:

Articulate the motivation behind service-oriented programming

Understand the concept of web services Understand the service-oriented architecture and

web service standards Build a web services using C# or Java Develop an application that uses a public web

services

Page 3: Service-Oriented Programming Introduction to service- oriented programming 1

3

Motivation: What does service-orientation mean?

What do we do when we have a complex problem? We decompose it into sub problems (i.e.,

abstraction). Object-Orientation defines an abstraction

on the level of objects. It allows to model, develop, and use software

components as objects. Service-Orientation defines an abstraction

on the level of services. It allows to model, develop, and use software

systems as services.

Page 4: Service-Oriented Programming Introduction to service- oriented programming 1

4

The evolution of Programming Abstractions

Figure: Evolution of Programming Abstractions (1)

(1) Dr. Marcello La Rosa, QUT, Introduction to Web Services

Page 5: Service-Oriented Programming Introduction to service- oriented programming 1

5

What is Service-Oriented Programming (SOP)? SOP is a programming paradigm that uses

“services” as the building block to develop software applications. Develop services. Invoke services. Combine services

Kernel component: Web Services

Page 6: Service-Oriented Programming Introduction to service- oriented programming 1

6

What is a Web Service? Naïve answer: a service on the Web… Different from a web application:

A web application is consumed by humans Such as http://www.weather.com

A web service is consumed by programs Such as Twitter APIs https://dev.twitter.com

/docs/api/1

Page 7: Service-Oriented Programming Introduction to service- oriented programming 1

7

What is a Web Service? (2) W3C (World Wide Web Consortium) definition:

A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specially WSDL (web service description language)). Other systems interact with the Web service in a manner prescribed by its description using SOAP (simple object access protocol) messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.

Page 8: Service-Oriented Programming Introduction to service- oriented programming 1

8

What is new in web services?

Global accessibility: A web service is available on the Web It leverages the powerful communication paradigm

of the web It is accessible via HTTP (cross firewall)

Standardization: WSDL: for service description (www.w3.org/TR/wsdl) UDDI (Universal Description, Discovery and

Integration): for service publish and discovery (http://uddi.xml.org/)

SOAP: for service invocation (www.w3.org/TR/SOAP/) More standards… They are XML-based…

Page 9: Service-Oriented Programming Introduction to service- oriented programming 1

9

More about web services A Web service can be:

A self-contained business task E.g., a funds withdrawal or funds deposit service self-contained means it does not need other resources business task is a simple step

A full-fledged business process E.g., the automated purchasing of office suppliers business process consists of several steps, or business tasks

An application E.g., a life insurance application

A service-enabled resource E.g., access to a particular back-end database containing

patient medical records

Page 10: Service-Oriented Programming Introduction to service- oriented programming 1

10

What web service brings to SOP?

Foster software reuse Deal with heterogeneity issues:

Using the same data types? Using the same programming languages? Using the same development platform? Using the same operating systems? Solution: provide XML-based Interfaces

XML is ubiquitous

traditional oop needs those items with ?

Page 11: Service-Oriented Programming Introduction to service- oriented programming 1

11

What web service brings to SOP? (2)

Deal with the accessibility issues: Downloading libraries and including in the

project? Solution: access to functionalities on the

web Use existing networking infrastructure HTTP is ubiquitous

traditional oop needs that

Page 12: Service-Oriented Programming Introduction to service- oriented programming 1

12

SOP as a new problem-solving methodology

Instead of develop an application to solve a complex problem from scratch, use the existing services: decompose the problem to sub problems, for each sub problem, select/or develop appropriate

services, compose these services together.

Page 13: Service-Oriented Programming Introduction to service- oriented programming 1

13

Current stage of SOP Major IT companies have led the efforts

Microsoft, IBM, HP, Oracle, BEA, Sun, SAP… A large number of web services online

Major IT companies deliver their functionalities as web services Microsoft, Yahoo!, Google, Facebook, Twitter, Bing, Amazon,

… you name it there are 5814 Web services and 6610 mashups (SOP

applications) published in programmableWeb. Other search engines

http://www.webservicelist.com/ http://www.biocatalogue.org/

…… The Web is taking a step to transform from an

information repository to a service repository

Page 15: Service-Oriented Programming Introduction to service- oriented programming 1

15

An Example of SOP Applications:

Suppose we want to develop a web-based hotel query application that allows users to view the information of hotels. Given a location Input: address Output: a list of hotels, local weather,

driving directions.

Page 16: Service-Oriented Programming Introduction to service- oriented programming 1

16

A SOP Example (2) The process of developing this application contains the

following steps: Develop a hotel service:

Input: address Output: a list of hotels

Develop a weather service: Input: address Output: local weather

Develop a route service: Input: two addresses Output: Driving directions

It is not trivial to develop any of the above services, so, let’s take a look at existing services on the web…

Page 17: Service-Oriented Programming Introduction to service- oriented programming 1

17

Hotel Service: Expedia APIs:

http://developer.ean.com/docs/read/hotels/Version_3

Input: city, state Output: the list of hotels (in Jason format)

name, average daily price, a short description

Demo. http://vhost3.cs.rit.edu/Application/

Page 18: Service-Oriented Programming Introduction to service- oriented programming 1

18

Weather Service:

Weather underground weather API http

://www.wunderground.com/weather/api/d/docs

Input: Geocode Output: current weather condition

weather, humidity, temperature, wind mph,…

Demo. http://vhost3.cs.rit.edu/Application/

Page 19: Service-Oriented Programming Introduction to service- oriented programming 1

19

Route Service The Google directions API

https://developers.google.com/maps/documentation/directions/

Input: origin, destination Output: Driving direction

duration, instructions, distances,… Demo

http://vhost3.cs.rit.edu/Application/

Page 20: Service-Oriented Programming Introduction to service- oriented programming 1

20

Behind SOP: Service-Oriented Architecture(SOA)

0.0000

Computer

Web Service

Web Service

0.0000

0.0000

ServiceRegistry

ServiceConsumer

ServiceProvider

Publish

Find

message

exchange

has defines

Service Description

UDDI Publication

UDDI Inquiry

SOAP

WSDL

UDDI Registry

Web Browser

Page 21: Service-Oriented Programming Introduction to service- oriented programming 1

21

Service-Oriented Architecture(SOA) Roles of interaction

Web services provider Owns the Web service and implements the business logic Hosts and controls access to the service e.g., Microsoft, Amazon, Facebook, …

Web services requestor Requires the certain functions to be satisfied Looks for and invokes the service e.g., a client program, a server, or another web service

Web services registry Searchable directory where service descriptions can be

published and searched e.g., UDDI registry

Page 22: Service-Oriented Programming Introduction to service- oriented programming 1

22

Operations in SOA

Publish operation Describing the Web service itself

Business information: information regarding the Web service provider or the implementer of the service

Service information: information about the nature of the Web service

Technical information: information about implementation details and the invocation methods for the Web service

Actual registration of the Web service Storing the three basic categories of descriptive

information about a service in the Web service registry

Page 23: Service-Oriented Programming Introduction to service- oriented programming 1

23

Operations in SOA (2) Find operation

Discovering the services in the registry of the discovery agency Search criteria: type of service, preferred price range,

products associated with the service, company category Can be specified

Statically at the design time to retrieve a service’s interface description for program developmentor

Dynamically (at run-time) to retrieve a service’s binding and location description for invocation.

Selecting the desired Web service from the search result Manual selection Automatic selection

Page 24: Service-Oriented Programming Introduction to service- oriented programming 1

24

Operations in SOA (3) Bind operation

Service requestor invokes or initiates an interaction at run-time using the binding details in the service description to locate and contract to the service.

Two possibilities: Direct invocation of the Web service by the

Web service requestor Mediation by the service agency when

invoking the Web service

Page 25: Service-Oriented Programming Introduction to service- oriented programming 1

25

Service-Oriented Programming

Web service standards and technologies: XML, WSDL, SOAP, REST.

Page 26: Service-Oriented Programming Introduction to service- oriented programming 1

26

XML XML: eXtensible Markup Language It is the universal format for structured

documents and data on the Web It is the common data format of Web

services It is a semi-structured data model

Page 27: Service-Oriented Programming Introduction to service- oriented programming 1

27

XML: Key concepts Document Elements Attributes Text Others: namespace declarations,

comments, processing instructions, …

Page 28: Service-Oriented Programming Introduction to service- oriented programming 1

28

Elements Enclosed in Tags:

book, title, author, … Start tag: <book> End tag: </book>

Empty element <red></red> OR <red/> Elements are ordered, may be repeated or

nested

Page 29: Service-Oriented Programming Introduction to service- oriented programming 1

29

Basic XML Tag Syntax Tags written as with HTML, but …

Case-sensitive names Always need end tags Special empty-element Always quote attribute values

Some other constraints for tags Start with a letter or underscore After 1st character, numbers, -, and . are allowed Cannot contain white-spaces.

Page 30: Service-Oriented Programming Introduction to service- oriented programming 1

30

Attributes Associated to Elements, …

<book price=“20”> Attributes are unordered. Attribute names must be unique. Attributes cannot be nested (good for

atomic value)

Page 31: Service-Oriented Programming Introduction to service- oriented programming 1

31

Attributes Attributes provide metadata for the

element The value of each attribute must be

enclosed in “ ” If an element contains several

attributes, then there is no comma in between

Same naming conventions as elements

Page 32: Service-Oriented Programming Introduction to service- oriented programming 1

32

Example:

<book price = “95” currency = “USD”> <title> Database System Concepts, 5th

Ed</title> <author> Silberschatz </author> … <year> 2006 </year></book>

Page 33: Service-Oriented Programming Introduction to service- oriented programming 1

33

WSDL WSDL: Web Service Description Language Pronounced “Whiz Dull” XML-based Why we need WSDL for web services?

Web services are designed to support machine-to-machine interaction

No human in the loop Needs a specified and self-explanatory

programming interface

Page 34: Service-Oriented Programming Introduction to service- oriented programming 1

34

What is included in a WSDL file?(1)

WSDL describes a service’s functionality A service interface:

a list of operations that can be invoked by service users, such as getRoute, getMap,…

for each operation a list of input parameters whose values need to be

provided by service users, such as zipcode, address, …

a list of output parameters whose value will be returned to service users, such as directions, map image, …

By parsing a WSDL file, a program can: determine if the service is suitable, how to format the request, how to handle the response.

Page 35: Service-Oriented Programming Introduction to service- oriented programming 1

35

What is included in a WSDL file?(2)

WSDL describes how to bind a service Messaging style Formatting (encoding) style Transport protocol:

such as http, smtp, soap WSDL describes where to locate a web

service a set of ports

A port defines the location of a web service, e.g., network address location or URL

By parsing a WSDL file, a program can: Locate and bind a web service

Page 36: Service-Oriented Programming Introduction to service- oriented programming 1

36

WSDL document content Abstract (interface) definitions

<types> data type definitions <message>operation parameters <operation>abstract description of service actions <portType> set of operation definitions

Concrete (implementation) definitions <binding> operation bindings <port> association of an endpoint with a binding <service> location/address for each binding

Page 38: Service-Oriented Programming Introduction to service- oriented programming 1

38

SOAP (Simple Object Access Protocol) It is the standard messaging protocol used by web services. It supports inter application communication.

Page 39: Service-Oriented Programming Introduction to service- oriented programming 1

39

SOAP (2) It codifies the use of XML as an encoding scheme for request

and responses parameters using HTTP as a means for transport.

Service providerService requestor

Application object(client)

Application object(service provider)

SOAP-based middleware

SOAP-based middleware

SOAP messages exchanged on top of, HTTP, SMTP, or other transport

Converts procedure calls to/from XML messages sent through HTTP or other protocols.

Page 40: Service-Oriented Programming Introduction to service- oriented programming 1

40

SOAP Message

SOAP messages are seen as enveloper where the application encloses the data to be sent.

A SOAP message consists of an <Envelope> element containing an optional <Header> and a mandatory <Body> element.

SOAP envelope

SOAP header

header block

SOAP body

body block

Page 41: Service-Oriented Programming Introduction to service- oriented programming 1

41

SOAP header Contains several header blocks Contains information relevant to:

Security, QoS values, transaction Example:

<env:Envelope xmlns:env=“http://www.w3.org/2003/05/soap-envelope” > … <env:Header> <tx:transaction-id xmlns:tx=”http://www.transaction.com/transaction”

env:mustUnderstand=”true”> 512

</tx:transaction-id> <notary:token xmlns:notary=”http://www.notarization-services.com/token” env:mustUnderstand=”true”> GRAAL-5YF3 </notary:token> </env:Header>

……………</env:Envelope>

Page 42: Service-Oriented Programming Introduction to service- oriented programming 1

42

SOAP Body The SOAP body is the area of the SOAP message, where the

application specific XML data (payload) being exchanged in the message is placed.

The <Body> element must be present and is an immediate child of the envelope. It may contain a number of child elements, called body entries, but it may also be empty. The <Body> element contains either of the following:

Application-specific data is the information that is exchanged with a Web service. The SOAP <Body> is where the method call information and its related arguments are encoded. It is where the response to a method call is placed, and where error information can be stored.

A fault message is used only when an error occurs.

A SOAP message may carry either application-specific data or a fault, but not both.

Page 43: Service-Oriented Programming Introduction to service- oriented programming 1

43

SOAP Body (Example)<?xml version='1.0' ?>

<env:Envelope xmlns:env="http://www.w3.org/2002/06/soap-envelope" >

<env:Header> <t:transactionID xmlns:t="http://intermediary.example.com/procurement" env:role="http://www.w3.org/2002/06/soap-envelope/role/next" env:mustUnderstand="true" > 57539 </t:transactionID> </env:Header>

<env:Body> <m:orderGoods env:encodingStyle="http://www.w3.org/2002/06/soap-encoding" xmlns:m="http://example.com/procurement"> <m:productItem> <name>ACME Softener</name> </m:productItem> <m:quantity> 35 </m:quantity> </m:orderGoods> </env:Body>

</env:Envelope>

Header

Body

Blocks

Envelope

Page 44: Service-Oriented Programming Introduction to service- oriented programming 1

44

Example of SOAP Request<SOAP-ENV:Envelope

xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/”>

<SOAP-ENV:Header>

<t:transId xmlns:t=“http://a.com/trans”>345</t:transId>

</SOAP-ENV:Header>

<SOAP-ENV:Body>

<m:Add xmlns:m=“http://a.com/Calculator”>

<n1>3</n1>

<n2>4</n2>

</m:Add>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Page 45: Service-Oriented Programming Introduction to service- oriented programming 1

45

Example of SOAP Response

<SOAP-ENV:Envelope

xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/”>

<SOAP-ENV:Header>

<t:transId xmlns:t=“http://a.com/trans”>345</t:transId>

</SOAP-ENV:Header>

<SOAP-ENV:Body>

<m:AddResponse xmlns:m=“http://a.com/Calculator”>

<result>7</result>

</m:AddResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Page 46: Service-Oriented Programming Introduction to service- oriented programming 1

46

More example: Sample SOAP Request and Response Message

for Google's Web Service Interface (illustration purpose only) http://www.w3.org/2004/06/03-google-soap-wsdl.

html

Page 47: Service-Oriented Programming Introduction to service- oriented programming 1

47

The SOAP Communication Model• SOAP supports two possible communication styles:

remote procedure call (RPC) and document (or message).

Request for

quote

Request for

quote

Quotedocument

Quotedocument

Web Service Definitions

Business Process Flow

Receive

Check

Send

Database

Request for

quote

Request for

quote

Quotedocument

Quotedocument

Web Service Definitions

Business Process Flow

Receive

Check

SendSend

Database

RPC-style interaction Document-style interaction

Page 48: Service-Oriented Programming Introduction to service- oriented programming 1

RPC-style SOAP Services• A remote procedure call (RPC)-style Web service appears as a

remote object to a client application. The interaction between a client and an RPC-style Web service centers around a service-specific interface. Clients express their request as a method call with a set of arguments, which returns a response containing a return value.

SOAP envelope

SOAP body

Method nameorderGoods

Input parameter 1product item

Input parameter 2quantity

SOAP envelope

SOAP body

Method return

Return valueorder id

Page 49: Service-Oriented Programming Introduction to service- oriented programming 1

<env:Envelope xmlns:SOAP=“http://www.w3.org/2003/05/soap-envelope” xmlns:m="http://www.plastics_supply.com/product-prices"> <env:Header>

<tx:Transaction-id xmlns:t=”http://www.transaction.com/transactions”

env:mustUnderstand='1'> 512

</tx:Transaction-id> </env:Header> <env:Body>

<m:GetProductPrice> <product-id> 450R6OP </product-id ></m:GetProductPrice >

</env:Body></env:Envelope>

<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> <product-price> 134.32 </product-price></m:GetProductPriceResponse>

</env:Body></env:Envelope>

Example of RPC-style SOAP body

Example of RPC-style SOAP response message

RPC-style web services

Page 50: Service-Oriented Programming Introduction to service- oriented programming 1

50

Document (Message)-style SOAP Services

o In the document-style of messaging, the SOAP <Body> contains an XML document fragment. The <Body> element reflects no explicit XML structure.

o The SOAP run-time environment accepts the SOAP <Body> element as it stands and hands it over to the application it is destined for, unchanged. There may or may not be a response associated with this message.

SOAP envelope

SOAP body

PurchaseOrderdocument

- product item- quantity

SOAP envelope

SOAP body

Acknowledgementdocument

- order id

Page 51: Service-Oriented Programming Introduction to service- oriented programming 1

51

<env:Envelope xmlns:SOAP=“http://www.w3.org/2003/05/soap-envelope”> <env:Header>

<tx:Transaction-id xmlns:t=”http://www.transaction.com/transactions”

env:mustUnderstand='1'> 512 </env:Header> <env:Body>

<po:PurchaseOrder oderDate=”2004-12-02” xmlns:m="http://www.plastics_supply.com/POs"> <po:from> <po:accountName> RightPlastics </po:accountName>

<po:accountNumber> PSC-0343-02 </po:accountNumber> </po:from> <po:to> <po:supplierName> Plastic Supplies Inc. </po:supplierName> <po:supplierAddress> Yara Valley Melbourne </po:supplierAddress> </po:to> <po:product> <po:product-name> injection molder </po:product-name> <po:product-model> G-100T </po:product-model> <po:quantity> 2 </po:quantity> </po:product>

</ po:PurchaseOrder > </env:Body></env:Envelope>

Example of document-style SOAP body

Example of document-style SOAP body

Page 52: Service-Oriented Programming Introduction to service- oriented programming 1

52

SOAP Fault elemento SOAP provides a model for handling faults. o It distinguishes between the conditions that result in a fault, and the ability

to signal that fault to the originator of the faulty message or another node. The SOAP <Body> is the place where fault information is placed.

<env:Envelope xmlns:SOAP=“http://www.w3.org/2003/05/soap-envelope” xmlns:m="http://www.plastics_supply.com/product-prices"> <env:Header>

<tx:Transaction-id xmlns:t=”http://www.transaction.com/transactions”

env:mustUnderstand='1'> 512

</tx:Transaction-id> </env:Header> <env:Body> <env:Fault> <env:Code> <env:Value>env:Sender</env:Value> <env:Subcode> <env:Value> m:InvalidPurchaseOrder </env:Value> </env:Subcode> </env:Code> <env:Reason> <env:Text xml:lang="en-UK"> Specified product did not exist </env:Text> </env:Reason> <env:Detail> <err:myFaultDetails xmlns:err="http://www.plastics_supply.com/faults"> <err:message> Product number contains invalid characters </err:message> <err:errorcode> 129 </err:errorcode> </err:myFaultDetails> </env:Detail> </env:Fault> </env:Body></env:Envelope>

Page 53: Service-Oriented Programming Introduction to service- oriented programming 1

53

REST Representational State Transfer

ResourceClienthttp://www.boeing.com/aircraft/747

Boeing747.html

Fuel requirementsMaintenance schedule

...

• The Client references a Web resource using a URL. • A representation of the resource is returned (in this case as an HTML

document).• The representation (e.g., Boeing747.html) places the client in a new state.

• When the client selects a hyperlink in Boeing747.html, it accesses another

resource. • The new representation places the client application into yet another state.

• Thus, the client application transfers state with each resource

representation.

Page 54: Service-Oriented Programming Introduction to service- oriented programming 1

54

Web Resource Can be:

Information from database e.g., invoice, resume, price, phone number,

… Image

e.g., map, photo,… Audio

e.g., song, speech,… Video

e.g., movie clip, Others…

Page 55: Service-Oriented Programming Introduction to service- oriented programming 1

55

Resource Representations Each resource is represented as a distinct

Uniform Resource Identifier (URI) Uniform Resource Name (URN)

e.g., isbn-10: 3642078885

or Uniform Resource Locator (URL)

e.g., http://www.imdb.com/title/tt0068646/?ref_=fn_al_tt_1

Page 56: Service-Oriented Programming Introduction to service- oriented programming 1

56

The REST Design Pattern

Create a resource for every service. Uniquely identify each resource with a logical

URL. Design your information to link to other

information. That is, the information that a resource returns to a client should link to other information in a network of related information.

Page 57: Service-Oriented Programming Introduction to service- oriented programming 1

57

The REST Design Pattern (cont.) All interactions between a client and a web

service are done with simple operations. Most web interactions are done using HTTP and just four operations: retrieve information (HTTP GET) create information (HTTP PUT) update information (HTTP POST) delete information (HTTP DELETE)

Page 58: Service-Oriented Programming Introduction to service- oriented programming 1

58

REST Principles: Statelessness Every HTTP request is isolated from others. Every HTTP request from client to server must

contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server.

All of the information related to application states is kept entirely on the client side. Application states are maintained if requests need

to be made in a certain order, for example: make payment after adding products to a shopping cart

Page 59: Service-Oriented Programming Introduction to service- oriented programming 1

59

Learn by Example Parts Depot, Inc has deployed some web

services to enable its customers to: get a list of parts get detailed information about a

particular part submit a Purchase Order (PO)

Page 60: Service-Oriented Programming Introduction to service- oriented programming 1

60

The REST way of Designing the Web Services

Web

Serv

er

HTTP POST URL 3PO

(HTML/XML)

HTTP GET request URL 1

HTTP responseURL to submitted PO

PartsList

PartData

PO

HTTP responseResponse(HTML/XML doc)

HTTP responseResponse(HTML/XML doc)

HTTP GET request URL 2

Page 61: Service-Oriented Programming Introduction to service- oriented programming 1

61

The First Web Service

o Service: Get a list of partso The web service makes an available URL to a parts

list resource. A client uses this URL to get the parts list:o http://www.parts-depot.com/partso Note that how the web service generates the parts list

is completely transparent to the client. This is loose coupling.

Page 62: Service-Oriented Programming Introduction to service- oriented programming 1

62

Data Returned - Parts List

<?xml version="1.0"?><Parts> <Part id="00345" href="http://www.parts-depot.com/parts/00345"/> <Part id="00346" href="http://www.parts-depot.com/parts/00346"/> <Part id="00347" href="http://www.parts-depot.com/parts/00347"/> <Part id="00348" href="http://www.parts-depot.com/parts/00348"/></Parts>

o Each resource is identified as a URL.

o Note that the parts list has links to get detailed info about each part.

o This is a key feature of the REST design pattern. The client transfers from one state to the next by examining and choosing from among the alternative URLs in the response document.

Page 63: Service-Oriented Programming Introduction to service- oriented programming 1

63

The second Web Serviceo Get detailed information about a particular part

o The web service makes available a URL to each part resource. For example, here's how a client requests a specific part:o http://www.parts-depot.com/parts/00345

o Data returned

<?xml version="1.0"?><Part> <Part-ID>00345</Part-ID> <Name>Widget-A</Name> <Description>This part is used within the frap assembly</Description> <Specification href="http://www.parts-depot.com/parts/00345/specification"/> <UnitCost currency="USD">0.10</UnitCost> <Quantity>10</Quantity></Part>

Page 64: Service-Oriented Programming Introduction to service- oriented programming 1

64

The Third Web Serviceo Submit a Purchase Order (PO)

o The web service allows users to create a new purchase order and insert it into the database. For example, here is a

HTTP request a user will make:o URL: http://www.parts-depot.com/PO/o Method: POSTo Request body:

o Returns:o 201 Created&Locationo 401 Unauthorizedo 415 Unsupported Media Type

<?xml version="1.0"?><PurchaseOrder> <PO-ID>2353423</PO-ID> <Date>01/14/2005</Date> <Customer-ID>1-0-32342</Customer-ID> <ItemNo>A-00832<ItemNo> <Quality>12<Quality> <Price>35<Price> <Total>420</Total></PurchaseOrder>

Page 65: Service-Oriented Programming Introduction to service- oriented programming 1

65

weather service: http://vhost3.cs.rit.edu/weather/Service.svcIMDB service:  http://vhost3.cs.rit.edu/IMDB/Service.svcCalculator service: http://vhost3.cs.rit.edu/Calculator/Service.svc

You can test the services via the following link:http://vhost3.cs.rit.edu/Application/here are some urls, source codes and documentations of sample serviceshttp://vhost3.cs.rit.edu//CentralRepository/index.aspx

Web Service Examples