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

Web Services

Distributed architecture
Waiting for Waiting for requests requests
(known location, (known location, known port) known port)

Communication protocol, Data format

Sending Sending requests, requests, getting getting results results

Basic questions are:


What kind of protocol to use, and what data to transmit What to do with requests on the server side

Traditional CGI-based approach


Waiting for Waiting for requests requests
(known location, (known location, known port) known port)

Data as name/value pairs

Sending Sending requests, requests, getting getting results results

cgi-bin scripts:
Data transmitted as name-value pairs (HTML forms) Transport over (state-less) HTTP protocol no standards for keeping user sessions (statefullness)

SOAP-based communication
Waiting for Waiting for requests requests
(known location, (known location, known port) known port)

Data in XML format

Sending Sending requests, requests, getting getting results results

SOAP:
Data in a well-defined XML format Transport over various protocols
HTTP, SMTP are the most used, perhaps because they are firewall-friendly

server side: either an RPC call or a message delivered

Web services

A collection of XML-based technologies developed by the e-business community to address issues of:

service discovery interoperable data exchange and/or application invocation service compositions (workflow, business processes) Apache, IBM, HP, SUN & Microsoft (.NET)

Major developers include:

http://www.webservices.org/

W3C (working group) definition

"A Web service is a software application identified by a URI, whose interfaces and bindings are capable of being defined, described and discovered as XML artefacts. A Web service supports direct interactions with other software agents using XML based messages exchanged via internet-based protocols."
http://www.w3c.org/TR/2002/WD-wsa-reqs-20020819

Web Services Architecture

Let a program click on a web page

Web Services Stack

SOAP

Simple Object Access Protocol

http://www.w3c.org/TR/SOAP/

A lightweight protocol for exchange of information in a decentralised, distributed environment Two different styles to use:

to encapsulate RPC calls using the extensibility and flexibility of XML or to deliver a whole document without any method calls encapsulated

XML Messaging Using SOAP

WSDL

Web Services Definition Language

http://www.w3.org/TR/wsdl/

An XML-based language for describing Web Services


what the service does (description) how to use it (method signatures) where to find the service

It does not depend on the underlying protocol But: It is not much human-readable

Hello.wsdl
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://localhost:8080/axis/services/Hello" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:SOAPENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:impl="http://localhost:8080/axis/services/Hello-impl" xmlns:intf="http://localhost:8080/axis/services/Hello" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:message name="setHelloMessageRequest"> <wsdl:part name="in0" type="xsd:string"/> </wsdl:message> <wsdl:message name="getHelloMessageResponse"> <wsdl:part name="return" type="xsd:string"/> </wsdl:message> <wsdl:message name="setHelloMessageResponse"> </wsdl:message> <wsdl:message name="getHelloMessageRequest"> </wsdl:message> <wsdl:portType name="HelloWorldService"> <wsdl:operation name="getHelloMessage"> <wsdl:input message="intf:getHelloMessageRequest"/> <wsdl:output message="intf:getHelloMessageResponse"/> </wsdl:operation> <wsdl:operation name="setHelloMessage" parameterOrder="in0"> <wsdl:input message="intf:setHelloMessageRequest"/> <wsdl:output message="intf:setHelloMessageResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HelloSoapBinding" type="intf:HelloWorldService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getHelloMessage"> <wsdlsoap:operation soapAction=""/> <wsdl:input> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="getHelloMessage" use="encoded"/> </wsdl:input> <wsdl:output> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/Hello" use="encoded"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="setHelloMessage"> <wsdlsoap:operation soapAction=""/> <wsdl:input> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="setHelloMessage" use="encoded"/> </wsdl:input> <wsdl:output> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/Hello" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HelloWorldServiceService"> <wsdl:port binding="intf:HelloSoapBinding" name="Hello"> <wsdlsoap:address location="http://localhost:8080/axis/services/Hello"/> </wsdl:port> </wsdl:service> </wsdl:definitions>

Universal Description, Discovery and Integration http://www.uddi.org

UDDI (and alternatives)

UDDI creates a platform-independent, open framework & registry for:


Describing services Discovering businesses Integrating business services

The UDDI may be less used than predicted, especially on the Internet level BioMoby - an alternative for Life Sciences domain?

BioMoby
http://biomoby.org

Java <=> XML Data Mapping

How Java objects are converted to/from XML data (in order to be able to be put into SOAP messages) Important especially for the non-basic data types Its easier if your non-basic data types are Java Beans (having set/get methods for members)

Outline
Question: What is a Web Service? Answer: Acronym Soup!
Fundamentals (XML+)

SOAP and REST WSDL

OGC Web Services

WFS, WCS, WFS

UNIDATA

LDM

NDG Web Services

Fundamentals of Web Ser vices


Web services stack
Packaging Layer The world before
Situation

Problems

Simple Object Access Protocol (SOAP) is a lightweight protocol designed for the exchange of information

WEB the encoding Defines a modular packaging model and


mechanisms for encoding data within modules.

Solutions

SERVICES

Probs. with Curr. sols.


Envelope Motiv.

Fund. Of Web Services

for Web Services


Web Services Solution

+ve and -ve of Web ServicesRPC representation SOAP

Encoding rules

Mahmoud Rabie Mahmoud - EGJUG 2006

What is a web service?


Googling gives:

Answers.Com: Web-based applications that dynamically interact with other Web applications using open standards that include XML, UDDI and SOAP. (Yuck: UDDI?)

emergingtech.ittoolbox.com:

A Service-Oriented Architecture (SOA) is a collection of services or software agents that communicate freely with each other. Sub-topic definition: Web Services protocols and standards are the technology that promote the sharing and distribution of information and business data. A protocol is a standard method for transmitting data through a network. There are many different specialized protocols to accommodate the many kinds of data that might be transmitted.

SOAP
Simple Object Access Protocol
Horrible looking XML specification, but lots of SOAP pacakges available which are (generally easy to use), eg:

from SOAPpy import SOAPproxy url=http://services.xmethods.net:80/soap/servl et/rpcrouter n=urn:xmethods-Temperature server=SOAPProxy(url,namespace=n) temperature=server.getTemp(27502) Returns the temperature at U.S. zipcode 27502 (from Dive Into Python, Mark Pilgrim) (One knew a priori that a method named getTEmp would return a float given an argument of a zip code,

provided one used the right namespace How?)

WSDL

:Web Services Description Language

>>>from SOAPpy import WSDL >>>Server=WDSL.Proxy(path/to/WSDL) >>>server.method.keys() [udoGoogleSearch,udoGetCachedPage ] >>>callInfo=server.methods[doGoogleSearch] >>>for arg in callInfo.inparams: . . . print arg.name, arg.type

key (uhttp://www.w3.org/2001/XMLSchema,ustring) . . .

Define expected messages for a service, and their (input or output parameters).

T Swill group together a number of An interface AB (operations) messages


Bind an Interface via a definition to a specific transport (e.g. HTTP) and messaging (e.g. SOAP) protocol

AC R

PR T

S IE RT PE O

The network location where the service is implemented , e.g. http://localhost:8080

RESTful Web Services

REST (representational state transfer) is an approach for getting information content from a Web site by reading a designated (ok, you need a URI) Web page that contains an XML (Extensible Markup Language) file that describes and includes the desired content. Thats it! You use HTTP (get,put,) to a URI, with XML as the payload

Web Services the confusion:


(Tim Ewald): Today, I see three camps: 1) It's all about SOAP messages , 2) It's all about WSDL, 3) It's all about XML/HTTP. Microsoft is definitely in the first camp, focusing on doing things with SOAP whether or not they are ultimately represented as XML or a binary data rep. IBM and Iona are in the second camp, focusing on describing in WSDL, whether or not they are ultimately represented as SOAP or a binary protocol. Lots of developers and some big companies like Amazon are in the XML/HTTP camp, focusing on getting data from one place to another in a way they can consume it.
[Tim Ewald: http://pluralsight.com/blogs/tewald/archive/2004/10/18/2875.aspx]

SOAP::Lite

a collection of (many) modules

but they are loaded automatically when needed

supports SOAP 1.1 specification all methods can be used for both setting and retrieving values:

if you provide no parameters, you will get current value, and if parameters are provided, a new value will be assigned to the object and the method in question will return the current object (if not stated otherwise) which is is suitable for stacking these calls like:
$lite = SOAP::Lite -> uri(openBQS') -> proxy('http://industry.ebi.ac.uk/soap/openBQS') ;

Why to use Web Services


(comparing to CORBA)

WS are easier to deploy because of their firewallfriendliness WS are quite well marketed (both from IT companies and Open Source projects) However:

user sessions are less standardised many parts yet-to-be-done (notification, transactions, security, etc.)

The programming effort and maintainability is similar to other distributed technologies

1. What is similar

The programming effort and maintainability is roughly the same both for Web Services and CORBA

For CORBA I need an ORB

but do you know anybody doing WS without a SOAP toolkit? not always (ask Perl folks) for WS you use frequently stubs generated from WSDL

For CORBA I need an IDL compiler


similar answers for valuetype/custom encoding, etc.

2. What is (IMHO) better

WS are easier to deploy because of their firewallfriendliness WS are quite well marketed (both from IT companies and Open Source projects) Integration of WS into workflows seems to be very dynamic and very real topic

comparing with CORBA Components

Fundamentals of Web Ser vices


Web services stack
Protocol Layer The world before
Situation

Problems

Any of the standard Internet protocols may be used to invoke web services over the network.

WEB

Solutions

The initial definition focuses specifically on HTTP/1.1 and the encrypted HTTPS Probs. with
Curr. sols.

SERVICES

FTP and SMTP can also be used

Fund. Of Web Services

Motiv. for Web Services


Web Services Solution

+ve and -ve of Web Services

Mahmoud Rabie Mahmoud - EGJUG 2006

Ser vice Oriented Ar ch.


Situation

It's an architectural style of building software applications that promotes Service The world loose coupling between components so that you can reuse them Problems Oriented before Arch.

WEB
SERVICES
Motiv. for Web Services +ve and -ve of Web Services

Solutions

Probs. with Curr. sols.

Fund. Of Web Services

Web Services Solution

Mahmoud Rabie Mahmoud - EGJUG 2006

Fundamentals of Web Ser vices


Web services stack
Service & Information Layer The world before
Situation

Problems

WEB
SERVICES
Service Implementation

Types

Solutions
Message Operation Port Type

Probs. with Curr. sols.

Fund. Of Web Services

Motiv. for Binding Web Services +ve and -ve of Web Services Web Service Interface (WSDL)
Mahmoud Rabie Mahmoud - EGJUG 2006

Port Web Services

Solution
Service

+ve and ve of Web Ser vices


Advantages of web services
The world before
Situation

Problems

Web services provide interoperability between various software applications running on disparate platforms/operating systems Web services use open standards and protocols SERVICES By utilizing HTTP, web services can work through common firewall security measures without requiring Motiv. for changes to the firewall filtering rules. Other forms of RPC Web Services may more often+ve blocked of be and -ve
Web Services
Probs. with many sols. Curr.

WEB

Solutions

Web Services Solution

Mahmoud Rabie Mahmoud - EGJUG 2006

+ve and ve of Web Ser vices


Advantages of web services
The world before
Situation

Web services allow software and services from different companies and locations to be combined easily to provide an integrated service. Web services allow theSERVICES reuse of services and components within an infrastructure. Web services are loosely coupled thereby facilitating a Motiv. for distributed approach to application integration. Web Services
+ve and -ve of Web Services

Problems

WEB

Solutions

Probs. with Curr. sols.

Web Services Solution

Mahmoud Rabie Mahmoud - EGJUG 2006

Fundamentals of Web Ser vices


Web services stack
The world before
Situation

Problems

WEB
SERVICES
Motiv. for Web Services +ve and -ve of Web Services

Solutions

Probs. with Curr. sols.

Fund. Of Web Services

Web Services Solution

Mahmoud Rabie Mahmoud - EGJUG 2006

History

Structured programming Object-oriented programming Distributed computing Electronic data interchange World Wide Web Web services

Who Was First?

What company first proposed the web services concept?


Hewlett-Packard's e-Speak in 1999 was an enabler for e-services Microsoft introduced the name "web services" in June 2000 MS "bet the company" on its web services strategy now every major vendor is a player

SOAP Basics

SOAP is often thought of as a protocol extension for doing Remote Procedure Calls (RPC) over HTTP. This is how it is often used. This is not accurate: SOAP is an XML message format for exchanging structured, typed data. It may be used for RPC in client-server applications May be used to send XML documents Also suitable for messaging systems (like JMS) that follow one-to-many (or publish-subscribe) models. SOAP is not a transport protocol. You must attach your message to a transport mechanism like HTTP.

Servlets/CGI Compared to Web Services


Browser Browser HTTP GET/POST Web Server WSDL GUI Client WSDL SOAP

WSDL

Web Server SOAP JDBC

WSDL

Web Server

JDBC DB

DB

Explanation of Previous Slide

The diagram on the left represents a standard web application.


Browsers converse with web servers using HTTP GET/POST methods. Servlets or CGI scripts process the parameters and take action, like connect to a DB. Separates visual from non-visual components Interactions may be either through the browser or through a desktop client (Java Swing, Python, Windows, etc.)

On the right, we have a Web services system.


Open, Standard Technologies

XML tagging data such that it can be exchanged between applications and platforms SOAP messaging protocol for transporting information and instructions between applications (uses XML)

Open, Standard Technologies

WSDL a standard method of describing web services and their specific capabilities (XML) UDDI defines XML-based rules for building directories in which companies advertise themselves and their web services

Advantages

Open, text-based standards Modular approach Inexpensive to implement (relatively) Reduce the cost of enterprise application integration Incremental implementation

The Big Picture


UDDI Registry

WSDL Document
Registry refers client to WSDL document WSDL provides data to interact with web service Web service returns SOAP-message response Client sends SOAP-message request

Client queries registry to locate servicedocument Client accesses WSDL

Client

Web Service Code

XML

Developed from Standard Generalized Markup Method (SGML) XML widely supported by W3C Essential characteristic is the separation of content from presentation XML describes only data Any application that understands XML can exchange data

XML

XML parser checks syntax If syntax is good the document is wellformed XML document can optionally reference a Document Type Definition (DTD), also called a Schema If an XML document adheres to the structure of the schema it is valid

SOAP

SOAP enables between distributed systems SOAP message has three parts

envelope wraps entire message and contains header and body header optional element with additional info such as security or routing body application-specific data being commuicated

WSDL

Web services are self-describing Description is written in WSDL, an XMLbased language through which a web service conveys to applications the methods that the service provides and how those methods are accessed WSDL is meant to be read by applications (not humans)

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