Web Services

35
1 Web Services - I Objectives: Background Component Technologies of Web Services Web services: Business view Web Services architecture Building blocks of a Web service application

description

 

Transcript of Web Services

Page 1: Web Services

1

Web Services - I

Objectives: Background Component Technologies of Web Services Web services: Business view Web Services architecture Building blocks of a Web service

application

Page 2: Web Services

2

Background In the 80s and 90s, client/server applications were

primarily data-centric in nature focus was more on retrieval and display of data than on

the business rules of the application

Web application architectures changed all of this Web applications are based on a distributed architecture Web applications tended more to a service-oriented

architecture Examples of inherently service-oriented distributed

technologies are• Remote Procedure Calls (RPC)• Remote Method Invocation (RMI)• Common Object Request Broker Architecture (CORBA)

Page 3: Web Services

3

Background Talking about service-oriented architecture, a few

things come up Common communication language A service providing application and a client application

using the service need to locate each other before they start talking

Hence, a basic service-oriented architecture for Web Services has: A standard way for communication A uniform data representation and exchange mechanism A standard meta language to describe the services offered A mechanism to register and locate Web Services-based

applications

Page 4: Web Services

4

Background Today’s Web is designed for application to

human interactions B2C e-commerce Non-automated B2B interactions

Since the Web is everywhere, we can do more E-marketplaces Open and automated B2B e-commerce Enhance resource sharing and distributed computing

In a nutshell,Web services is an effort to build a distributed

computing platform for the Web

Page 5: Web Services

5

Component Technologies of Web Services

Consider a scenario in which you need to locate a particular pharmacy store in your area You might refer the Web site of the pharmacy on the

Internet If you knew the pharmacy's Web site, you would look

it up directly and find the location through the store locator link

If not, you would go to a search engine and type out the name of the pharmacy in the language that the search engine was meant to recognize

After getting the location, you would find the directions to the store, and then go to the store

Page 6: Web Services

6

Component Technologies of Web Services

Consider a scenario in which you need to locate a particular pharmacy store in your area You might refer the Web site of the pharmacy on the

Internet If you knew the pharmacy's Web site, you would look it up

directly and find the location through the store locator link If not, you would go to a search engine and type out the

name of the pharmacy in the language that the search engine was meant to recognize

After getting the location, you would find the directions to the store, and then go to the store

Web Services provide for each of these above described activities

Page 7: Web Services

7

Component Technologies of Web Services

SOAP (Simple Object Access Protocol) is the method by which you can send messages across different modules This is similar to how you communicate with the search

engine that contains an index with the Web sites registered in the index associated with the keywords

UDDI (Universal Description, Discovery, and Integration) is the global look up base for locating the services In our example, this is analogous to the index service for

the search engine, in which all the Web sites register themselves associated with their keywords. It maintains a record of all the pharmacy store locations throughout the country

Page 8: Web Services

8

Component Technologies of Web Services

WSDL (Web Services Definition Language) is the method through which different services are described in the UDDI This maps to the actual search engine in our example

Page 9: Web Services

9

Technology Stack of Web Services

Layer Technology Description

Uniform data representation and exchange

XML Extended Markup Language (XML) is a meta language that has a well-defined syntax and semantics. The syntax and semantics "self describing" features of XML make it a simple, yet powerful, mechanism for capturing and exchanging data between different applications.

XML is a tried and tested way for exchanging data and has been extensively used in B2B applications. Hence, XML is used in the Web Services architecture as the format for transferring information/data between a Web Services provider application and a Web Services client application.

Standard communication channel

SOAP The Simple Object Access Protocol (SOAP) is the channel used for communication between a Web Services provider application and a client application. The simplicity of SOAP is that it does not define any new transport protocol; instead, it re-uses the Hyper Text Transfer Protocol (HTTP) for transporting data as messages. This use of HTTP as the underlying protocol ensures that Web Services provider applications and client applications can communicate using the Internet as the backbone. It is the use of SOAP that multiplies the capabilities of Web Services and make it all the more exciting!

Standard meta language to describe the services offered

WSDL Web Services provider applications advertise the different services they provide using a standard meta language called the Web Services Description Language (WSDL). Interestingly, WSDL is based on XML and uses a special set of tags to describe a Web service, services provided, where to locate it, and so forth. Client applications obtain information about a Web service prior to accessing and using a Web service of a Web Service provider.

Registering and locating Web Services

UDDI The "yellow pages" of Web Services is the Universal Description Discovery and Integration (UDDI). Web Services application providers are listed in a registry of service providers using UDDI. Similarly, client applications locate Web Services application providers using UDDI. Like in the case of WSDL, UDDI also is based on XML.

Page 10: Web Services

10

Building a Web Services application

The basic building blocks in a Web services application are summarized in the following table

Service Provider Service User

Define the services that will be provided Identify the services that will be required

Implement the functionality behind the services Locate the Web service by querying a directory service

Deploy the service provider application Send the request to the service

Publish the Web services with a directory service Receive the response from the service

Wait for processing client requests

Page 11: Web Services

11

Web Services: Business view In the business world, Web services provide a

mechanism of communication between two remote systems, connected through the network of the Web Services In case of a merger or an acquisition, companies don't

have to invest large sums of money developing software to bring the systems of the different companies together

By extending the business applications as Web Services, the information systems of different companies can be linked

Page 12: Web Services

12

Web Services: Business view

Page 13: Web Services

13

Architecture of Web Services

These steps will be the same irrespective of which major technology/programming language that you use

to implement the Web service

Page 14: Web Services

14

Underlying standards The basic standards for web services are:

XML (Extensible Markup Language)

SOAP (simple object access protocol)

WSDL (web services description language)

UDDI (universal description, discovery and integration)

Page 15: Web Services

15

Web Services Architecture Web Services involve three major roles

Service Provider Service Registry Service Consumer

Three major operations surround web services Publishing – making a service available Finding – locating web services Binding – using web services

Page 16: Web Services

16

Web Service Model

Page 17: Web Services

17

Towards a Service-Oriented Architecture (SOA)

Page 18: Web Services

18

SOA and Web services Businesses that successfully implement an SOA

using Web services have the following advantages: Services aligned with strategic IT business goals can

react more quickly to changing business requirements than those who have IT systems aligned to a particular execution environment

It's easier to combine Web services, easier to change Web services compositions, and cheaper to change the Web services and XML data than it is to change execution environments

The advantages and benefits of SOA with Web services include

• A better return on investment for IT spending on projects• A faster time to results for the projects• The ability to more quickly respond to changing business

and government requirements Any business that can implement an IT infrastructure

that allows it to change more rapidly has an advantage over a business that cannot do the same

Page 19: Web Services

19

Making a service available (1)

In order for someone to use your service they have to know about it

To allow users to discover a service it is published to a registry (UDDI)

To allow users to interact with a service you must publish a description of it’s interface (methods & arguments) This is done using WSDL

Page 20: Web Services

20

Making a service available (2) Once you have published a description of your service

you must have a host set up to serve it

A web server is often used to deliver services

This is functionality which has to be added to the web server. In the case of the apache web server a ‘container’ application (Tomcat) can be used to make the application (servlet) available to apache (deploying)

Page 21: Web Services

21

The old transfer protocols are still there. Like the grid architecture web services

is layered on top of existing, mature transfer protocols

HTTP, SMTP are still used over TCP/IP to pass the messages

Web services, like grids, can be seen as a functionality enhancement to the existing technologies

Page 22: Web Services

22

XML

All Web Services documents are written in XML

<SOAP-ENV:Body> <s:SearchRequest

xmlns:s="http://www.xmlbus.com/SearchService"> <p1>Skate</p1>

<p2>boots</p2> <p3>size 7.5</p3> </s:SearchRequest>

</SOAP-ENV:Body> </SOAP-ENV:Body>

Page 23: Web Services

23

XML NAMESPACES The XML namespaces recommendation defines a way to

distinguish between duplicate element type and attribute names

An XML namespace is a collection of element type and attribute names. The namespace is identified by a unique name, which is a URI

Thus, any element type or attribute name in an XML namespace can be uniquely identified by a two-part name: the name of its XML namespace and its local name

This two-part naming system is the only thing defined by the XML namespaces recommendation

XML namespaces are declared with an xmlns attribute, which can associate a prefix with the namespace

Page 24: Web Services

24

Purpose of XML namespaces XML namespaces are designed to provide

universally unique names for elements and attributes. This allows for the followings: Combine fragments from different documents

without any naming conflicts Write reusable code modules that can be

invoked for specific elements and attributes Universally unique names guarantee that such

modules are invoked only for the correct elements and attributes

Define elements and attributes that can be reused in other schemas or instance documents without fear of name collisions

Page 25: Web Services

25

Purpose of XML namespaces: Example <?xml version="1.0" ?> <Address>

<Street>Wilhelminenstr. 7</Street> <City>Darmstadt</City>

<State>Hessen</State> <Country>Germany</Country>

<PostalCode>D-64285</PostalCode>

<?xml version="1.0" ?> <Server>

<Name>OurWebServer</Name> <Address>123.45.67.8</Address>

</Server>

Page 26: Web Services

26

SOAP

Defines the format of messages on the 'wire'

Actually used to communicate with the Web Service

Both the request and the response are SOAP messages

The body of the message (whose grammar is defined by the WSDL) is contained within a SOAP “envelope”

“Binds” the client to the web service

Page 27: Web Services

27

SOAP Today's applications communicate using Remote

Procedure Calls (RPC) between objects like DCOM and CORBA

RPC represents a compatibility and security problem firewalls and proxy servers will normally block this kind of

traffic A better way to communicate between applications

is over HTTP HTTP is supported by all Internet browsers and servers

SOAP was created to accomplish this SOAP provides a way to communicate between

applications running on different operating systems, with different technologies and programming languages

Page 28: Web Services

28

SOAP A SOAP message is an ordinary XML

document containing the following elements: 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

All the elements above are declared in the default namespace for the SOAP envelope

Page 29: Web Services

29

SOAP Attachment

Large quantities or binary data may not fit well into a XML SOAP message.

In which case it can be sent ‘out of band’ by attaching it to a SOAP message

Analogy : email attachments

SOAP BODY

SOAP ENVELOPE

FAULT

SOAP HEADER

Transport protocol

MIME header

Attachment

Page 30: Web Services

30

Skeleton SOAP Message <?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:Header> ... ... </soap:Header><soap:Body> ... ... <soap:Fault> ... ... </soap:Fault> </soap:Body></soap:Envelope>

Page 31: Web Services

31

Attaching a file to a SOAP message

To add a file to a SOAP message a tag is added within the body of the message

<?xml version=‘1.0’ encoding=‘UTF-8’?><SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”

xmlns:xsi=“http://www.w3c.org/1999/XMLSchema-instance”xmlns:xsd=“http://www.w3c.org/1999/XMLSchema”><SOAP-ENV:Body>

<attachment href=“{URL}”/>

</SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 32: Web Services

32

What is WSDL

WSDL stands for Web Services Description Language

WSDL is written in XML WSDL is an XML document WSDL is used to describe Web services WSDL is also used to locate Web services WSDL is not yet a W3C standard

Describes the Web Service and defines the functions that are exposed in the Web

Service

Page 33: Web Services

33

What is WSDL

WSDL is a document written in XML The document describes a Web service The document specifies the location of the

service and the operations (or methods) the service exposes

Page 34: Web Services

34

UDDI

UDDI is used to register and look up services with a central registry

Service Providers can publish information about their business and the services that they offer

Service consumers can look up services that are available by

• Business• Service category• Specific service

Page 35: Web Services

35

UDDI