WEB SERVICES

58
1 WEB SERVICES WEB SERVICES Giảng viên: Giảng viên: Phạm Trần Vũ Phạm Trần Vũ Nhóm trình bày: Nhóm trình bày: Vũ Văn An Vũ Văn An Mã Trường Chu Mã Trường Chu Bùi Thị Dự Bùi Thị Dự Lê Thị Kim Tuyến Lê Thị Kim Tuyến Trần Thị Cẩm Tú Trần Thị Cẩm Tú

description

WEB SERVICES. Giảng viên: Phạm Trần Vũ Nhóm trình bày: Vũ Văn An Mã Trường Chu Bùi Thị Dự Lê Thị Kim Tuyến Trần Thị Cẩm Tú. Outline. I. SOA II. Introduction to Web Service - PowerPoint PPT Presentation

Transcript of WEB SERVICES

Page 1: WEB SERVICES

1

WEB SERVICESWEB SERVICESWEB SERVICESWEB SERVICES

Giảng viên:Giảng viên:

Phạm Trần VũPhạm Trần Vũ

Nhóm trình bày:Nhóm trình bày:

Vũ Văn AnVũ Văn An

Mã Trường ChuMã Trường Chu

Bùi Thị DựBùi Thị Dự

Lê Thị Kim TuyếnLê Thị Kim Tuyến

Trần Thị Cẩm TúTrần Thị Cẩm Tú

Page 2: WEB SERVICES

22

OutlineI. SOAII. Introduction to Web ServiceIII. Web Service’s Architecture 1. SOAP 2. WSDL 3. UDDIIV. ReferencesV. DemoVI. Q&A

Page 3: WEB SERVICES

33

SOA - WHAT IS IT?SOA - WHAT IS IT?SOA stands for SOA stands for SService ervice OOriented riented AArchitecture.rchitecture.SOA is a mechanism that enables SOA is a mechanism that enables organizations to facilitate communication organizations to facilitate communication between the systems running on multiple between the systems running on multiple platformsplatformsSOA is a collection of well-defined services, SOA is a collection of well-defined services, each individual service can be modified each individual service can be modified independently of other services to help respond independently of other services to help respond to the ever-evolving market conditions of a to the ever-evolving market conditions of a businessbusiness

SOA presents the big picture of what you can SOA presents the big picture of what you can do with web servicesdo with web services

Page 4: WEB SERVICES

44

SOA - WHY USE IT?Using SOA can:• Enhance business agility • Synchronize IT with your business • Break the barriers between business units and

business partners • Lower the cost of maintaining IT systems • Focus your resources on innovation rather than

maintenance • Speed delivery of web services to meet business

demands • Provide support for IT process automation • Protect IT investments by building on your

existing infrastructure

Page 5: WEB SERVICES

55

SOA - ADVANTAGESBusiness benefits: Focus on Business Domain solutions Leverage Existing Infrastructure AgilityTechnical Benefits Loose Coupling Autonomous Service Location Transparency Late Binding

Page 6: WEB SERVICES

66

SOA – DISAVANTAGE & APPLICABILITY

• Service Oriented Architecture may not always be the best architectural choice because optimal utilization of SOA requires additional development and design attempts as well as infrastructure which translates into costs escalation.

Page 7: WEB SERVICES

77

SOA - Roles• Service Provider

– Provides a stateless, location transparent business service

• Service Registry– Allows service

consumers to locate service providers that meet required criteria

• Service Consumer– Uses service providers

to complete business processes

Service Registry

Service Provider

Service Consumer

Page 8: WEB SERVICES

88

SOA - OPERATIONS

Publish: To be accessible, service description must be published so that it can be discovered and invoked by a service consumer.

Find: A service requestor locates a service by querying the service registry for a service that meets its criteria.

Bind and invoke: After retrieving the service description, the service consumer proceeds to invoke the service according to the information in the service description.

Page 9: WEB SERVICES

99

SOA - ELEMENTS

Page 10: WEB SERVICES

1010

SOA - An example• Storage Service

– Storing and retrieving data– Reserving space, monitoring status of storage

service– Querying and defining the policies that govern who

is allowed access the service.

• Data Transfer Service– Provide operations for requesting the transfer of

data from one storage service to another– Managing and monitoring such transfers– Querying and defining policies that govern how

difference transfer requests are prioritized.

• Troubleshooting Service

Page 11: WEB SERVICES

1111

Introduction to Web Introduction to Web serviceservice

1.1. What are Web Services?What are Web Services?

2.2. Why use it?Why use it?

3.3. When use it?When use it?

4.4. XMLXML

Page 12: WEB SERVICES

1212

1. What is Web service?• Web Service

Essential Book: A web service is

any service that is available over the Internet, uses a standardized XML messaging system, and is not tied to any one operating system or programming language

XMLXML

Computer A:Language: Perl

OS: Windows 2000

Computer B:Language: Java

OS: Linux

A basic web service

Page 13: WEB SERVICES

1313

1. What is Web service? (cont)

• W3C:– A software system designed to

support interoperable machine-to-machine interaction over a network

• W3schools.com:– Application components– Communicate using open protocols– Self-contained and self-describing– Can be used by other applications

Page 14: WEB SERVICES

1414

2. Why use web service?

• Interoperability has highest priority• Web Services take Web-applications to

the next level• Web Services have two types of uses

– Reusable application-components – Connect existing software

Page 15: WEB SERVICES

1515

2. Why use web service? (cont)

• Web services facilitate collaboration and allow businesses to grow

• Companies can spend less time developing new applications

• E-businesses can use Web services to provide their customers with enhanced shopping experiences

Page 16: WEB SERVICES

1616

3. When use web service?• Applications do not have severe

restrictions on reliability and speed• Two or more organizations need to

cooperate– One needs to write an application that uses

another’s service• Services can be upgraded

independently of clients– Google can improve PageRank

implemenation without telling user– Just don’t change the WSDL

Page 17: WEB SERVICES

1717

Web Service

1. What are Web Services?2. Why use it?3. When use it?4. XML (eXtensible Markup

Language)

Page 18: WEB SERVICES

1818

4. XML

• 4.1. A bout XML• 4.2. The difference between XML

and HTML

Page 19: WEB SERVICES

1919

4.1. About…

• XML - eXtensible Markup Language• XML is a markup language much like

HTML• XML tags are not predefined. You

must define your own tags• XML is designed to be self-descriptive

Page 20: WEB SERVICES

2020

4.1. About…• XML does not do anything• With XML, you invent your own tags• XML just plain text

<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

Page 21: WEB SERVICES

2121

4.2. The difference between XML and HTML

XML• Designed to transport

and store data, with focus on what data is

• Carrying information• Provides a facility to

define tags and the structural relationships between them

HTML• Designed to display

data, with focus on how data looks

• Displaying information

• Both the tag semantics and the tag set are fixed

Page 22: WEB SERVICES

22

WEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTURE

SOAPSOAPSimple Object Access Simple Object Access

ProtocolProtocol

Page 23: WEB SERVICES

2323

What is SOAP?• The Service Oriented Architecture

Protocol• Protocol for messaging and remote

procedure calling between distributed applications– SOAP is for exchange information

between applications– SOAP is a format for sending messages– SOAP is platform and language

independent• Developed by the World-Wide-Web

Consortium (W3C)

Page 24: WEB SERVICES

2424

What is SOAP?

• Encoded in XML• Stateless (request/response)• SOAP is simple and extensible • SOAP messages work through proxies

and firewalls

Page 25: WEB SERVICES

2525

SOAP in a Nutshell• A SOAP client formats a message in XML

including a SOAP “envelope” element describing the message

• The client sends the message to a SOAP server in the body of an HTTP request

• The server determines whether the message is valid and supported

• The server formats its response in XML and sends it to the client in the body of an HTTP response

Page 26: WEB SERVICES

26

SOAP Use Scenario: RPC

SOAP envelope

SOAP envelope

Page 27: WEB SERVICES

2727

SOAP Message Components• Envelope (required) : identifies the XML

document as a SOAP message – Contains Header and Body

• Header (optional) : contains header information – Contains application-specific information

about the SOAP message. – Specifies which entries must be

understood and by which target “actor” in chain of recipients

Page 28: WEB SERVICES

2828

SOAP Message Components

• Body (required)– Contains application-specific

message– May be encoded variously

• Fault element (optional)– Contained in Body– Describes error class (version

mismatch, headers not understood, client error, server error)

Page 29: WEB SERVICES

2929

Skeleton SOAP Message <?xml version="1.0"?><soap:Envelope<soap:Header>...</soap:Header>

<soap:Body>...  <soap:Fault>  ...  </soap:Fault></soap:Body>

</soap:Envelope>

Page 30: WEB SERVICES

3030

The HTTP Protocol

• HTTP communicates over TCP/IP. An HTTP client connects to an HTTP server using TCP. After establishing a connection, the client can send an HTTP request message to the server:– POST /item HTTP/1.1Content-Type: application/soap+xml;

Page 31: WEB SERVICES

3131

The HTTP Protocol

• The server then processes the request and sends an HTTP response back to the client. The response contains a status code that indicates the status of the request:– 200 OKContent-Type:application/soap+xml;

Page 32: WEB SERVICES

3232

SOAP HTTP Binding

• A SOAP method is an HTTP request/response that complies with the SOAP encoding rules.

HTTP + XML = SOAP

Page 33: WEB SERVICES

3333

A SOAP Example

• In the example below, a GetStockPrice request is sent to a server. The request has a StockName parameter, and a Price parameter that will be returned in the response. The namespace for the function is defined in "http://www.example.org/stock".

Page 34: WEB SERVICES

3434

A SOAP request• POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml;

<?xml version="1.0"?><soap:Envelope><soap:Body xmlns:m="http://www.example.org/stock">  <m:GetStockPrice>    <m:StockName>IBM</m:StockName>  </m:GetStockPrice></soap:Body></soap:Envelope>

Page 35: WEB SERVICES

3535

The SOAP response• HTTP/1.1 200 OKContent-Type: application/soap+xml;

<?xml version="1.0"?><soap:Envelope><soap:Body xmlns:m="http://www.example.org/stock">  <m:GetStockPriceResponse>    <m:Price>34.5</m:Price>  </m:GetStockPriceResponse></soap:Body></soap:Envelope>

Page 36: WEB SERVICES

36

WEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTURE

WSDLWSDLWeb Services Web Services

Description LanguageDescription Language

Page 37: WEB SERVICES

37

Definition

• WSDL is an XML-based language used to define Web Services and describe how to access them

• When someone wants to use your service, they request the WSDL file in order to find out the location of the service, the function calls and how to access them

• Then they use this information in your WSDL file to form a SOAP request to the computer

Page 38: WEB SERVICES

38

WSDL Elements• Types• Messages• Interfaces (portTypes)• Bindings• Services

Page 39: WEB SERVICES

39

Types• Describes all the data types used between the client

and server• WSDL is not tied exclusively to a specific typing

system<types> <schema targetNamespace="http://example.com/stockquote.xsd"

xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all><element name="tickerSymbol" type="string"/></all> </complexType> </element> <element name="TradePrice"> <complexType> <all><element name="price" type="float"/></all> </complexType> </element> </schema> </types>

Page 40: WEB SERVICES

40

Messages

• The <message> element is used to define the messages that will be exchanged between the client and the service

• Contains zero or more message <part> elements, which can refer to message parameters or message return values.

Page 41: WEB SERVICES

41

Messages<message name="SayHelloRequest">

<part name="firstName" type="xsd:string"/>

</message>

<message name="SayHelloResponse"> <part name="greeting"

type="xsd:string"/> </message>

Page 42: WEB SERVICES

42

portTypes

• Combines multiple message elements to form a complete one-way or round-trip operation

<portType name="Hello_PortType"> <operation name="sayHello"> <input message="tns:SayHelloRequest"/> <output message="tns:SayHelloResponse"/> </operation> </portType>

Page 43: WEB SERVICES

43

Types of operation

Page 44: WEB SERVICES

44

Bindings

• Define the mechanism that the client will actually use to interact with the web service

• Provide concrete information on what protocol is being used

• The most common choice is currently SOAP

Page 45: WEB SERVICES

45

Services• The service element defines the address for

invoking the specified service. • Most commonly, this includes a URL for

invoking the SOAP service

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

Page 46: WEB SERVICES

46

EditorsHow do you write WSDL files?• By hand: some editors have

special support for WSDL !• Automatic generation

Page 47: WEB SERVICES

47

WEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTUREWEB SERVICE’S ARCHITECTURE

UDDIUDDIUniversal Description, Universal Description,

Discovery and IntegrationDiscovery and Integration

Page 48: WEB SERVICES

4848

Introduction to UDDI

• Universal description discovery and integration(UDDI) is special directory services which is implemented to use for indexing all the available services, a company offer.

• UDDI - an XML-based standard for describing, publishing, and finding Web services

Page 49: WEB SERVICES

4949

Introduction to UDDI

Page 50: WEB SERVICES

5050

Why UDDI ?

• At a first glane appears extremely simple

• Nonetheless, it include some subtle points that are easily overlooked.

• Let’s therefore begin examining the future impact of UDDI within a specific a industry.

• Currently, approximately 700 companies in the information technology, electronic component.

Page 51: WEB SERVICES

5151

Why UDDI ?

• Enables a partner to transfer the contents of an electronic shopping cart

• Enables a partner to query status on a specific shipment

Page 52: WEB SERVICES

5252

UDDI technical overview

The UDDI technical architecture consists of three parts:

• UDDI data model• UDD API• UDDI cloud services

Page 53: WEB SERVICES

5353

UDDI Data Model

Page 54: WEB SERVICES

5454

Searching UDDI

• When you install Windows Server 2003, it does not install Enterprise UDDI Services by default.

• Install the Web service on a new or existing Web server.

Page 55: WEB SERVICES

5555

Publishing to UDDI

• In this section, we will walk through the steps involved in publishing a Web service with the UDDI interface.

• Publish the specifications of the Web service with Enterprise UDDI Services.

Page 56: WEB SERVICES

5656

UDDI Implementations

• A number of UDDI implementations are currently available.

• Here is a brief synopsis of the main UDDI implementations available.– Java– Microsoft COM – Perl

Page 57: WEB SERVICES

5757

References

• [1] Web Services Essentials Ethan Cerami ISBN: 0-596-00224-6

• www.w3schools.com• www.arts-humanities.net/briefingpaper/web_s

ervices• www.neodynamic.com/ND/

FaqsTipsTricks.aspx?tabid=66&prodid=0&sid=52

• Nguyen Ngoc Duy’s Thesis - 2004

Page 58: WEB SERVICES

58

THANKS FOR YOUR THANKS FOR YOUR ATTENTIONS!!!!!!ATTENTIONS!!!!!!

THANKS FOR YOUR THANKS FOR YOUR ATTENTIONS!!!!!!ATTENTIONS!!!!!!

DemoDemo

Q & AQ & A