Вы находитесь на странице: 1из 61

Web Services Technology

COMP3150/7700 E-technology Architectures, Tools and Applications (Semester 1, 2010/11)

Some software functional block Location, platform, code are irrelevant Loosely coupled software components that encapsulate discrete functionality and that are accessible over standard Internet protocols.The Stencil Group Web Services are a new breed of web application. They are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web. IBM Web services are a form of distributed information system Gustavo Alonso
Web services: concepts, architectures and applications

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Outline
Client-Server to 3-Tier Middleware Technology Web services

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Outline
Client-Server to 3-Tier Middleware Technology Web Services

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Different Layers of an Information System


Client

Presentation Layer Application Logic Layer Res. Management Layer Information System

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Different Layers of an Information System


Conceptual Layers of an IS
Presentation Layer For interacting with external entities (clients) for receiving requests & sending responses. Application logic Layer For system/process integration, business rule/logic
execution, References for business rules: http://www.businessrulesgroup.org/

Resource Management Layer Data sources from databases or other information systems, specialized computing services,

Client

Presentation Layer Information System

Application Logic Layer

Res. Management Layer

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

From 1-tier to 3-tier


1-tier
UI

2-tier
UI

3-tier
Client
UI

Client

Presentation Layer

Presentation Layer

Presentation Layer

Server
Application Logic Layer
Res. Management Layer Application Logic Layer Res. Management Layer

Application Logic Layer

Res. Management Layer

Middleware
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 7

Application Framework
User Interface Userware Presentation Interface Task Management
A P P L I C A T I O N

Middleware

Control Integration

Data Repository Enterpriseware System Service Hardware Computer and Communication Facility
8

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Integration: 2-tier Approach


(data-oriented)
Rice A Rice B

combined catalog
UI Presentation Layer 1

Rice B
Drink C Drink C Food D Food D Food E

e.g., html or xml


Application Logic Layer

All logics are embedded in your web programs (e.g., *.asp, *.php, )

Res. Management Layer

e.g., html or xml

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Integration: 3-tier Approach


Rice A Rice B Rice B Drink C Drink C ...

(data-oriented)
Client

Presentation Layer

e.g., html or xml


Application Logic Layer

e.g., The rule can be: If a source is not html or xml responding, show service not available e.g., ODBC/Vendor_Specific_Protocol and send a notification Res. Management Layer e-mail to Manager A Eg., database and . management system
(Oracle, DB2)
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 10

Eg., integration rules & exception handling rules (declarative)

Integration: 2-tier Approach


(computation-oriented)

UI Presentation Layer 1

e.g., analysis results in html/xml


Logics for analysis are embedded in the web programs.

e.g., html or xml


Application Logic Layer Res. Management Layer

e.g., student essays (*.doc)

Problem: The server is overloaded when the number of students increases.


11

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Integration: 3-tier Approach


(computation-oriented)
UI

Presentation Layer

e.g., html or xml


Application Logic Layer

e.g., student essays (*.doc)

Products that support Java Message Service: Apache ActiveMQ, Oracle AQ, IBM MQ, etc.

Eg., integration via message queues


e.g., JMS/Vendor-Specific-Protocol
Res. Management Layer

Eg., database management system


(Oracle, DB2)
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 12

Outline
Client-Server to 3-Tier Middleware Technology Web Services

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

13

Middleware Technologies 101 RPC -> Workflow


Web Process Design

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

14

Middleware Technologies: RPC -> Workflow


Middleware to handle the execution complexity for distributed applications Remote Procedure Call (RPC)
a process in a computer invokes a process in another synchronous (wait until the response is ready)

Going beyond simple RPC


Transactional
with commit and rollback handling (error handling)

Message-oriented (e.g., Oracle AQ)


asynchronous, enabled by message queue

Message-brokering (e.g., Oracle Message Broker)


from O(nxn) to O(n) communication support logic-dependent routing

Workflow Management System (e.g., Oracle Workflow)


process flow status control Workflow --The automation of a business process, in whole or part, during which documents, information or tasks are passed from one participant (resource or human or machine) to another for action, according to a set of procedural rules.
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 15

Globalization of Processes
EAI B2B E-Services

Workflows
Enterprise

Distributed Workflows
Inter-Enterprise

Web Processes
Global
16

Processes driving the Networked Economy COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

Outline
Client-Server to 3-Tier Middleware Technology 101 Web Services

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

17

Software as Services? Examples?

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

18

Service-Oriented Architecture (SOA)


3 fundamental operations:
publish find bind

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

19

Web Services (1) What is


Web Services Software systems designed to support interoperable machine-to-machine interaction over a network.(W3C) Messages in-between are XML-based Internet based Remote Procedure Call (RPC) Request/Response (so, synchronous essentially) Web Service Description Language (WSDL) A XML-based markup language for specifying interfaces for consuming services over the network.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

20

Web Services (2) What is


UDDI Universal Description, Discovery and Integration A platform-independent XML-based registry for businesses worldwide to list themselves on the Internet. SOAP Simply Object Access Protocol A protocol for exchanging XML-based messages over computer networks by HTTP/HTTPS.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

21

How can UDDI be Used


industry published an UDDI standard for flight rate checking and reservation; airlines register their services into an UDDI directory. Travel agencies search the UDDI directory to find the airline's reservation interface. The travel agency can communicate with the service immediately because it uses a welldefined reservation interface.
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 22

Who is Supporting UDDI?


UDDI is supported by all major platform and software providers, like Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, and Sun.
Over 220 companies are members of the UDDI community.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

23

Service-Oriented Architecture (SOA)


3 fundamental operations:
publish find bind
2
Store the meta data of web services, including where to locate the WSDL descriptions and support search.

Implement a web service Define its WSDL

3 1. Look up service broker for web services


2. Develop a client program that can communicate with the web service (based on the WSDL description) and then consume the web service.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

24

Web Services Roles


Service provider
Implements the services Makes the services available on the web

Service requestor
Consumes the web services

Service registry
Logically centralized registry provides a central place where allows developers to publish new services or search (or discover) existing ones

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

25

Web Services Procedures (1)

WS Search & Discovery

Service Registry UDDI

Register

Service Requester

SOAP Request SOAP Response

Service Provider

Retrieve WSDL Documents

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

26

Web Services Procedures (2)


1. Web services providers register in UDDI Registry. 2. Web service consumers discover the desired web services in UDDI server. 3. Consumers retrieve the WSDL documents from desired web service providers. 4. Consumers send SOAP request messages to service providers. 5. Providers receive the requests, process them request, and return SOAP responses.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

27

Web Services Description Language (WSDL)


4 critical pieces of information <portType>: describes a web service, the operations performed by the web service (the most important). <message>: defines the data elements of an operation. <type>: defines the data type used by the web service. <blinding>: defines the message format and protocol details for each port.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

28

WSDL Support 4 Basic Operation Types

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

29

Binding to SOAP

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

30

Binding Element
The binding element has two attributes name, type Name: defines the name of the binding (you can use any name you want). Type: points to the port for the binding, in this case the "glossaryTerms" port.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

31

SOAP: Binding
The soap:binding element has two attributes - style, transport Style: could be "rpc" or "document". Transport defines the SOAP protocol to use. In this case we use HTTP.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

32

Operation
The operation element defines each operation that the port exposes. --For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded. In this case we use "literal".

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

33

Visit this following link for more detailed specification http://www.w3.org/TR/wsdl#_wsdl

HelloServices.wsdl (1)
<?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloService" targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Definition

<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/> </message> <message name="SayHelloResponse"> <part name="greeting" type="xsd:string"/> </message>

Message

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

34

previous slides

HelloServices.wsdl (2)
<input message="tns:SayHelloRequest"/> <output message="tns:SayHelloResponse"/>

<portType name="Hello_PortType"> <operation name="sayHello">

</operation> </portType>

PortType
matched operations

<binding name="Hello_Binding" type="tns:Hello_PortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="sayHello"> <soap:operation soapAction="sayHello"/>

rpc - simple data types document xml documents/data

<input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:helloservice" use="encoded"/> </input> <output> <soap:body namespace="urn:examples:helloservice" use="encoded"/> </output> </operation> COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) </binding> 35

Binding

encoded with data types based on encodingStyle literal no encoding

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

HelloServices.wsdl (3)
previous slides <service name="Hello_Service"> <documentation>WSDL File for HelloService</documentation>

<port binding="tns:Hello_Binding" name="Hello_Port">


<soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/> </port> </service> </definitions>

Service

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

36

What is SOAP?
SOAP stands for Simple Object Access Protocol SOAP is XML-based SOAP is a protocol for accessing a Web Service SOAP is for communication between applications SOAP is a format for sending messages SOAP is via Internet (HTTP) SOAP is platform independent SOAP is language independent SOAP will be developed as a W3C standard

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

37

SOAP Building Blocks


A required Envelope element that identifies the XML document as a SOAP message An optional Header element that contains header information A required Body element that contains call and response information An optional Fault element that provides information about errors that occurred while processing the message

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

38

Syntax Rules
A SOAP message MUST be encoded using XML A SOAP message MUST use the SOAP Envelope namespace A SOAP message MUST use the SOAP Encoding namespace A SOAP message must NOT contain a DTD reference A SOAP message must NOT contain XML Processing Instructions

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

39

SOAP Message

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

40

Skeleton SOAP Message

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

41

Envelope Element
The xmlns:soap namespace The encodingStyle attribute --soap:encodingStyle="URI" --<soap:Envelope xmlns:soap="http://www.w3.org/2001/12 /soap-envelope" soap:encodingStyle="http://www.w3.org /2001/12/soap-encoding">

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

42

Header Element
Actor ---A SOAP message may travel from a sender to a receiver by passing different endpoints along the message path. The SOAP actor attribute is to address the Header element to a particular endpoint mustUnderstand=0/1 ---It is to indicate whether a header entry is mandatory or optional for the recipient to process. encodingStyle

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

43

Header Element
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soapencoding"> <soap:Header> <m:Trans xmlns:m="http://www.w3schools.com/transaction/" soap:mustUnderstand="1">234 soap:actor="http://www.w3schools.com/appml/ </m:Trans> </soap:Header> ... ... </soap:Envelope>

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

44

Body Element

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

45

Fault Element
Fault element has the following sub elements:

Value of faultcode
Error VersionMismatch MustUnderstand Client Server Description Found an invalid namespace for the SOAP Envelope element An immediate child element of the Header element, with the mustUnderstand attribute set to "1", was not understood The message was incorrectly formed or contained incorrect information There was a problem with the server so the message could not proceed
46

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

SOAP Hand-shaking
Example: weather services (refer to the link provided on course home page)

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

47

SOAP Hand-shaking (Request)


Envelope contains namespaces which directs to the external schema Body contains the request getTemp
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <zipcode xsi:type="xsd:string">10016</zipcode> </ns1:getTemp> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Envelope Body

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

48

SOAP Hand-shaking (Response)


Envelope contains the same namespaces Body contains the payload type (getTempResponse), corresponding to our initial request
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:getTempResponse xmlns:ns1="urn:xmethods-Temperature" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:float">71.0</return> </ns1:getTempResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Envelope
Body

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

49

SOAP over HTTP


SOAP Request
Sent via HTTP GET or POST HTTP POST requests specifies at least two HTTP headers: Content-Type and ContentLength.

SOAP Response
Delivered by HTTP with corresponding status code

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

50

SOAP Request

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

51

SOAP Response

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

52

Universal Description, Discovery and Integration (UDDI)


UDDI stores the web services providers and their web services provided in a common XML format, acted as a registry and database of web services Web-based applications interact with a UDDI registry using SOAP messages

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

53

UDDI Registry Categories


White
High-level business information Company name Description Contact info Known Identifiers (Thomas, DUNS, tax ID, etc.)

Yellow
Classification of business and services Uses widely known classification schemes such as NAICS, UN/SPSC (ECMA), SIC, and geographic taxonomies

Green
Technical info for consuming the service Called a Type Model (tModel) Defines the services API, binding requirements, and so on Usually a pointer to a WSDL document

http://www.uddi.org/schema/uddi_v2.xsd
COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services) 54

What is the role of Web Services for middleware?


2-tier
UI

3-tier
Client
UI

Client

Presentation Layer

Presentation Layer

Server
Application Logic Layer Res. Management Layer

Application Logic Layer

Res. Management Layer

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

55

More on Web Services


We are only talking about Web services as RPC so far (stone age concept)!!! Asynchronous request/response
Production and transmission of a request by a client. Consumption of the request by service provider. Production and transmission of a response by service provider. Consumption of the response by the client.

* Can you see a collaboration activity? * Can you define several web services to support that? Study which web services should be made known to client and which should be made known to service provider.

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

56

More on Web Services


WS-Coordination (a step towards asynchronous WS)
describes how services can make use of pre-defined coordination contexts to subscribe to a particular role in a collaborative activity.

WS-Transaction (a step towards transactional WS)


provides a framework for incorporating transactional semantics into coordinated activities.

Business Process Execution Language - BPEL (a step towards workflow)


describe how Web services are connected to create reliable and dependable business solutions

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

57

References
http://www.w3schools.com/ Darren Barefoot, Web Services Primer, Sept 2002, http://www.capescience.com/education/primer/index.sht ml New to Web Services, http://www106.ibm.com/developerworks/webservices/newto E Cerami, Web Services Essentials, OReilly, Feb 2002 David S. Linthisum, B2B Application Integration, Addison Wesley, 2001

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

58

..\code1.JPG

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

59

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

60

COMP3150/COMP7700 E-technology Architectures, Tools and Applications (Web Services)

61

Вам также может понравиться