Web Service Ali Kamandi kamandi@ce.sharif.edu Sharif University of - - PowerPoint PPT Presentation

web service
SMART_READER_LITE
LIVE PREVIEW

Web Service Ali Kamandi kamandi@ce.sharif.edu Sharif University of - - PowerPoint PPT Presentation

Web Service Ali Kamandi kamandi@ce.sharif.edu Sharif University of Technology Internet Engineering (CE317) Spring 2007 Service Oriented Architecture (SOA) There is an increase trend for sharing resource/data both within companies and


slide-1
SLIDE 1

Web Service

Ali Kamandi kamandi@ce.sharif.edu Sharif University of Technology Internet Engineering (CE317) Spring 2007

slide-2
SLIDE 2

2

Service Oriented Architecture (SOA)

  • There is an increase trend for sharing resource/data both

within companies and among companies

  • In a SOA, the complete value chain within the company is

divided into small services.

  • Focus on how services are described and organized to support

the dynamic, automated discovery and use.

  • Companies should be able to easily provide services. Others

can use these services.

slide-3
SLIDE 3

3

Requirements of SOA

Interoperability between different systems and

programming languages. (Use standards; platform independent)

Clear and unambiguous description language Retrieval of the service

slide-4
SLIDE 4

4

Service-Oriented Architecture

Consists of three basic components

slide-5
SLIDE 5

5

What is Web Services (1)

A Web Service is a software component

platform-independent, language-independent

Web Services can be used to realize service oriented

architecture.

Web services are modular applications that can be

described, published, located, and invoked over a network

slide-6
SLIDE 6

6

What is Web Services (2)

The Web technologies used:

XML (Extensible Markup Language) SOAP (Simple Object Access Protocol) allow

client to call remote service. The msg format is XML.

WSDL (Web Services Description Language) UDDI (Universal Description, Discovery, and

Integration) a standard used for publishing/query web services

slide-7
SLIDE 7

7

Short History of Web Services (1)

HTTP protocol facilitates Human-to-

Application (H2A) communications.

There is an increasing demand for

Application-to-Application communication using existing techniques.

HTTP is not adequate for more complex

  • perations. E.g., remote operation
slide-8
SLIDE 8

8

Short History of Web Services (2)

Late 1999, Microsoft published SOAP an XML-

based protocol.

IBM supports SOAP early 2000. May 2000 W3C Note: SOAP 1.1. The term Web services was coined several months

later, when WSDL was published.

March 2001 W3C Note: WSDL1.1 2002, UDDI 1.0 were also introduced

slide-9
SLIDE 9

9

A Brief History …

slide-10
SLIDE 10

10

HTTP Vs. Web Service

slide-11
SLIDE 11

11

More About Web Services

Your Web service will sit behind a Web server,

typically Internet Information Server (IIS).

Support loosely coupled connections between

systems.

Works through existing proxies and firewalls. Can take advantage of HTTP authentication. Web services only receive and return XML. Provide a stateless model.

slide-12
SLIDE 12

12

Advantages

  • Advantages of Web services over previous

distributed component architectures (OMG's CORBA, Microsoft's DCOM, or Java RMI):

  • near-universal agreement on standards
  • really running across multiple platforms
  • loosely specified and coupled
  • build on top of existing infrastructure like HTTP

and XML.

slide-13
SLIDE 13

13

Web Service URI

Every Web service has its home, where it lives. Its address is defined by a URI (URL). This address is often called an endpoint For exampe: http://localhost:6060/ChatService/

slide-14
SLIDE 14

14

Components

Web services are based on 3 main

underlying technologies

SOAP WSDL (Web Services Description Language) UDDI (Universal Discovery, Description, and

Integration)

slide-15
SLIDE 15

15

Components

slide-16
SLIDE 16

16

Components

slide-17
SLIDE 17

17

When to Use Web Services?

  • 1. Where applications need to communicate

across platform boundaries and over the Internet:

  • 2. Business to Business Integration
  • 3. Application Integration
slide-18
SLIDE 18

18

Software reuse has always been limited by one

key factor: you can reuse the code but not the data behind the code.

Web services let you reuse code along with the

data it needs.

Example: validating email address, city, zip

code.

Building an application that aggregates the

functionality of several other applications

Software Reuse

slide-19
SLIDE 19

19

When Not to Use Web Services

Single Machine Applications Applications that need to communicate with others running on the same machine. In this case, it is almost always better to use a native API rather than a Web service because they require relatively little overhead. Homogeneous Applications on a LAN Homogenous applications running on the same machine

  • r on different machines that need to communicate on

the same LAN.

slide-20
SLIDE 20

20

Web Service Review

Service Side

  • Write the service code

–Expects SOAP as input

  • Define the externally visible methods
  • Create the WSDL description of those methods
  • Publish the WSDL
  • Run the service

Client Side

  • Locate the WSDL
  • Load the WSDL
  • Convert to a client proxy
  • Write the client code, calling proxy

–Generates and sends SOAP

slide-21
SLIDE 21

21

How does it work?

With Web services, you have a server and a client. It's comparable to the ordinary HTML-based

Internet, where you have an HTTP-based Web server that responds to Web browser requests by sending HTML pages.

By contrast, with Web services there's an HTTP-

based SOAP server that listens for SOAP requests from client applications.

The SOAP server interprets the requests and then

replies to the client.

slide-22
SLIDE 22

22

How does it work?

The reply might consist of

a description of the server's available Web

services, presented in WSDL;

data encapsulated in a well-formed XML

document

slide-23
SLIDE 23

23

How does it work?

SOAP requests could

  • launch applications and pass data to an application

server

  • trigger a database operation
slide-24
SLIDE 24

24

Exchange Scenarios

You can have different exchange scenarios

One-way message scenarios Request-response scenarios (when a request

document must be followed with the response document)

slide-25
SLIDE 25

25

SOAP

What is SOAP?

  • SOAP stands for Simple Object Access Protocol
  • simple (to use, not necessarily to write)
  • to let applications exchange information over HTTP (via

Internet).

  • SOAP is XML based communication protocol
  • SOAP is for communication between applications
slide-26
SLIDE 26

26

SOAP

What is SOAP?

  • SOAP is a format for sending messages
  • SOAP is platform independent
  • SOAP is language independent
  • SOAP is based on XML
  • SOAP allows you to get around firewalls
slide-27
SLIDE 27

27

The Envelope

The SOAP envelope is analogous to the

envelope of an actual letter.

It supplies information about the message:

data relating to the recipient and sender details about the message itself.

slide-28
SLIDE 28

28

SOAP Request Example

POST /InStock HTTP/1.1 Host: www.stock.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.stock.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>

slide-29
SLIDE 29

29

SOAP Response Example

HTTP/1.1 200 OK Content-Type: application/soap; 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.stock.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>

slide-30
SLIDE 30

30

SOAP Benefits

Language/Platform Independence Easy to use Is sent over HTTP

Which allows you to get around tricky issues like

firewalls

slide-31
SLIDE 31

31

Disadvantages of SOAP

  • Based on HTTP, and is therefore
  • Stateless
  • Based on a request/response architecture – Implies no callback

functionality

  • Performance is slightly degraded for the following reasons:
  • An XML processor needs to be loaded each time to parse a SOAP

request/response

  • Currently supports only parameter serialization by value
slide-32
SLIDE 32

32

Web Services Standards Stack: Key Elements

  • Network

XML Messaging (Individual) Service Description

  • Composition
  • Discovery
slide-33
SLIDE 33

33

What is UDDI?

  • Universal Description, Discovery, and Integration
  • UDDI deals with registering and discovery of Web services.
slide-34
SLIDE 34

34

UDDI Overview

UDDI defines the operation of a service registry:

Data structures for registering SOAP Access API Global/Private registry

slide-35
SLIDE 35

35

UDDI continued

The data captured within UDDI is divided into three main categories:

  • White Pages: This includes general information about a specific
  • company. For example, business name, business description, and

address.

  • Yellow Pages: This includes general classification data for either the

company or the service offered. For example, this data may include industry, product, or geographic codes based on standard taxonomies.

  • Green Pages: This includes technical information about a Web
  • service. Generally, this includes a pointer to an external specification,

and an address for invoking the Web service.

slide-36
SLIDE 36

36

How are Web Services Described?

Web Services are described using WSDL

(Web Services Description language).

WSDL is an XML-based grammar for

describing Web services, their functions, parameters, and return values.

slide-37
SLIDE 37

37

WSDL

It enables developers to describe a Web service's

characteristics in a format readable by other Web services.

When a Web service is first invoked, it replies with a

WSDL message that describes the Web service's capabilities and how to communicate with it

slide-38
SLIDE 38

38

WSDL

.NET’s web service infrastructure will

automatically generate the necessary WSDL to fully describe a .NET web service.

As extended IDL: WSDL allows tools to

generate compatible client and server stubs.

slide-39
SLIDE 39

39

Web Services Description Language

  • Provides functional description of network services:
  • IDL description
  • Protocol and deployment details
  • Platform independent description.
  • Extensible language.
  • A de facto industry standard.
slide-40
SLIDE 40

40

WSDL Structure

portType

Abstract definition of a service (set

  • f operations)

Multiple bindings per portType:

How to access it SOAP, JMS

Ports

Where to access it

slide-41
SLIDE 41

41

Main Structure of

!"# $% &' ( ' )( ' *' )*' +( ' ) +( ' ,*' ),*' +-' )+-' )'

slide-42
SLIDE 42

42

Ports

  • The +( ' element is the most important WSDL element: it

defines

  • a web service
  • the operations that can be performed, and
  • the messages that are involved
  • The +' defines the connection point to a web service, an instance of

+( '

  • It can be compared to a function library (or a module, or a class) in a

traditional programming language

  • Each operation can be compared to a function in a traditional

programming language

slide-43
SLIDE 43

43

<?xml version="1.0"?> <serviceDescription xmlns:s0="http://tempuri.org/" name="TerraService" targetNamespace="http://tempuri.org/" xmlns="urn:schemas-xmlsoap-org:sdl.2000-01-25"> <httpget xmlns="urn:schemas-xmlsoap-org:get-sdl-2000-01-25"> <service> <requestResponse name="GetPlaceList" href="http://207.46.235.37/terranet/terraservice.asmx/GetPlaceList"> <request> <param name="placeName"/> <param name="MaxItems"/> <param name="imagePresence"/> </request> <response> <mimeXml ref="s0:ArrayOfPlaceFacts"/> </response> </requestResponse> </service> </httpget> </serviceDescription>

slide-44
SLIDE 44

44

Proxy Classes

The Proxy class is responsible for the following:

  • Generate SOAP request
  • Send to the target service
  • Receive the SOAP response
  • Parse the SOAP Generate an object
  • Return the object as a result

The proxy class can be generated automatically using

the command-line utility wsdl.exe.

Client Proxy

  • bject

RMI- IIOP JMS/ MQ SOAP/ HTTP

slide-45
SLIDE 45

For More Information SOAP !" WSDL !" # UDDI