38
WSDL-Web Service Description Language By Shin Chuan , Lin July / 8 /2003

WSDL-Web Service Description Language

Embed Size (px)

DESCRIPTION

WSDL-Web Service Description Language. By Shin Chuan , Lin July / 8 /2003. Topic Covered. Introduction Structure of WSDL document Example of WSDL Difference between WSDL 1.2 and WSDL 1.1 How to use WSDL file ? Reference. Introduction. What is WSDL ? - PowerPoint PPT Presentation

Citation preview

Page 1: WSDL-Web Service Description Language

WSDL-Web Service Description Language

By Shin Chuan , Lin

July / 8 /2003

Page 2: WSDL-Web Service Description Language

Topic Covered

Introduction Structure of WSDL document Example of WSDL Difference between WSDL 1.2 and WSDL

1.1 How to use WSDL file ? Reference

Page 3: WSDL-Web Service Description Language

Introduction

What is WSDL ? Stands for Web Service Description Language It’s an XML document for describing web services Further considers that an interface represents the behavior of a resource on the World Wide Web

What can we know from WSDL ? What kind of message is exchanged ? How are the message related ?(e.q operation input or output) How SOAP messages are exchanged ?

Page 4: WSDL-Web Service Description Language

What is WSDL ?

Page 5: WSDL-Web Service Description Language

Structure of WSDL document

Type Messages interfaces(Port Types)WSDL1.2 Bindings Protocol – html , smtp Encoding Service

“Interface” definition

“endpoint” definition

Page 6: WSDL-Web Service Description Language

Structure of WSDL document

<definitions><types>definition of types</types><message>definition of message</message><interface>definition of interface</interface><binding>definition of biding</binding><services>definition of endpoint </endpoint></definitions>

Page 7: WSDL-Web Service Description Language

Structure of WSDL document :definitions

Definitions Component is just a container for two categories of component:

(1)WSDL Component: messages, interface , binding and services (2)Type System Component: element declartions and type

definitions drawn from some type system . Definitions are represented in XML by one or more

WSDL information Sets(Infosets). A WSDL InfoSet contains representations of a collection of

WSDL components which share a common target namespace.

Page 8: WSDL-Web Service Description Language

Structure of WSDL document :Types

The types element encloses data type definitions that are relevant for the exchanged messages. WSDL prefers the use of XML Schema .

FROM<type>

<xsd:schema …/>

</type>

Page 9: WSDL-Web Service Description Language

An Example of WSDL Types

<tpyes><schema targetNamespace = “http://examploe.com/stockquote.xsd”><element name=“TradePrice”><all><element name=“price” type=“float”/></all></complex Type></element></schema></type>Note: (1) Use element form(2) Array types should extend the Array type from SOAP v1.1 encoding schema

( http://schemas.xmlsoap.org/soap/encoding)

Page 10: WSDL-Web Service Description Language

Structure of WSDL document :Message

The message component describes the abstract format of a particular message that Web service sends or receives .

Combine with binding to describe how the abstract content is mapped into a concrete format .

From:<messages name = “”><target namespace><part name = “” element= “” type =“”?/>…<message>

Page 11: WSDL-Web Service Description Language

An Example of WSDL Message

<message name=“InputParameters”> <part name = “firstname” type=“xsd:string”/><part name = “age” type=“xsd:int”/></message><message name=“OutputParameters”><part name=“id” type=“xsd:int”/></message>What does this mean ?Int get_id(string firstname , int age)

Page 12: WSDL-Web Service Description Language

An Example of WSDL Message

name : local name of messagepart component : describes a portion of a particular message that a

web service sends or receives .type : describe the format of a partelement : carrier information about its type system

Page 13: WSDL-Web Service Description Language

Structure of WSDL document :interface

The interface element is core WSDL element . It describes a set of messages that a service sends and/or receives , by grouping related messages into operations.

Operations include : One-way transmission The endpoint receives a message Request-response The endpoint receives a message

and sends a correlated message Solicit-Response The endpoint sends a message and receives

correlated message . Notification The endpoint sends a messge

Page 14: WSDL-Web Service Description Language

Structure of WSDL document :interface

Form: <definitions><interface><operation name =“xs:NCNAME” pattern=“xs:anyURI”<documentation/>?[ <feature/> | <property/> | [<input/> | <output/> | <infault /> | <outfault/>]+]*</operation></interface></definitions>

Page 15: WSDL-Web Service Description Language

Structure of WSDL document :interface(cont1)

Operation :An interface operation component describes an operation

that a given interface supports. An operation is a set of message references and an associated message pattern.

Message references are references either to messages accepted by this operation(input message) ,or messages send by this operation(output messages) . Such messages could be ordinary messages or fault messages .

fault element specify the abstract message format for any error messages that may be output as the result of the operation

Page 16: WSDL-Web Service Description Language

Structure of WSDL document :interface(cont2)

{message pattern} A URI identifying the message pattern used by the operation.

{message references}A set of message reference components for the ordinary messages the operation accepts or send .

{fault references}A set of fault reference components for the fault messages the operation accepts or sends.

{features} A set of named feature definitions used by the operation

{properties} A set of named property definitions used by the operation.

Page 17: WSDL-Web Service Description Language

Example of interface

<interface name="TicketAgent"><operation name="listFlights“ parameterOrder="depart origin destination">

<input message= "tns:listFlightsRequest" name= "listFlightsRequest"/><output message= "tns:listFlightsResponse“ name= "listFlightsResponse"/> </operation>

Page 18: WSDL-Web Service Description Language

Example of interface(cont1)

<operation name = "reserveFlight“ parameterOrder= "depart origin destination flight"><input message= "tns:reserveFlightRequest“ name= "reserveFlightRequest"/><output message= "tns:reserveFlightResponse“ name="reserveFlightResponse"/></operation></interface>

Page 19: WSDL-Web Service Description Language

Structure of WSDL document :Bindings

A binding defines message format and protocol details for operations and messages defined by a particular interface .

WSDL (Version 1.2): Bindings [WSDL 1.2 Bindings] defines such bindings for SOAP 1.1 [SOAP 1.1], SOAP 1.2 [SOAP 1.2 Part 1: Messaging Framework], HTTP [IETF RFC 2616] and MIME [IETF RFC 2045]. Other specifications MAY define additional binding details

Page 20: WSDL-Web Service Description Language

Structure of WSDL document :Bindings

From<binding name=““ interface=“”>

<operation name=“”>

<input name=“”?></input>

<output name=“”?></output>

<fault name=“”></fault>

</operation>

</binding>

Note : A binding MUST specify exactly one protocol

Page 21: WSDL-Web Service Description Language

Example of binding

<binding name=“Binding1” type=“record”><soap:binding style=“document”Transport=http://schemas.xmlsoap.org/soap/http/><operation name=“get_id”>

<soap:operationsoapAction =“http://example.com/get_id”><input>

<soap:body use =“literal”/></input><output>

<soap:body use=“literal”/></output>

</operation></binding>

Page 22: WSDL-Web Service Description Language

Structure of WSDL document :Service

A service component describes one and only one interface that a service provides, and the endpoints it is provided over.

Page 23: WSDL-Web Service Description Language

Structure of WSDL document :Service

Forms:<definitions> <service name= "xs:NCName" interface="xs:QName" targetResource="xs:anyURI"? > <documentation />? <endpoint />* </service> </definitions>

Page 24: WSDL-Web Service Description Language

Structure of WSDL document :Service

An endpoint component defines the particulars of a specific end-point at which a given service is available.

The properties of the Endpoint Component are as follows:

{name} An NCName as defined by [XML Namespaces]. {binding} A named binding component

For each endpoint component in the {endpoints} property of a service component the {name} property must be unique.

Page 25: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<?xml version="1.0"?><definitions name="StockQuote“ targetNamespace=http://example.com

/stockquote.wsdlxmlns:tns=http://example.com/stockquote.wsdlxmlns:xsd1=http://example.com/stockquote.xsd xmlns:soap=http://schemas.xmlsoap.org/wsdl

/soap/

xmlns="http://schemas.xmlsoap.org/wsdl/">

Page 26: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<message name="SubscribeToQuotes">

<part name="body“ element="xsd1:SubscribeToQuotes"/> <part name="subscribeheader“ element="xsd1:SubscriptionHeader"/>

</message>

Page 27: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<interface name="StockQuoteInterface">

<operation name="SubscribeToQuotes"><input message="tns:SubscribeToQuotes"/></operation>

</interface>

Page 28: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<binding name="StockQuoteSoap“ type="tns:StockQuoteInterface"> <soap:binding style="document“ transport="http://example.com/smtp"/> <operation name="SubscribeToQuotes"> <input message="tns:SubscribeToQuotes"> <soap:body parts="body" use="literal"/> <soap:header message="tns:SubscribeToQuotes“ part="subscribeheader" use="literal"/> </input> </operation></binding>

Page 29: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<service name="StockQuoteService"><endpoints name="StockQuoteEndpoint“ binding="tns:StockQuoteSoap"><soap:address

location="mailto:[email protected]"/>

</endpoints> </service>

Page 30: WSDL-Web Service Description Language

Example of WSDLSOAP binding of one-way operation over

SMTP using a SOAP Header

<types><schema targetNamespace=http://example.com/stockquote.xsd xmlns="http://www.w3.org/2000/10/XMLSchema">

<element name="SubscribeToQuotes"><complexType><all> <element name="tickerSymbol" type="string"/> </all></complexType></element> <element name="SubscriptionHeader" type="uriReference"/>

</schema></types></definitions>

Page 31: WSDL-Web Service Description Language

What does it mean?

In the above example , a SubscribeToQuotes SOAP 1.1 one-way message is sent to a StockQuote service via a SMTP binding. The request takes a ticker symbol of type string, and includes a header defining the subscription URI.

Page 32: WSDL-Web Service Description Language

Difference between WSDL1.2 and WSDL1.1

Operation Overloading WSDL 1.1 supported operation overloading and WSDL

1.2 removes it. This section will provide some rationale for it and provide hints on how to work around some scenarios.

PortTypes Port types have been renamed to interfaces. We now

have interface inheritance. Ports Ports have been renamed to endpoints.

Page 33: WSDL-Web Service Description Language

Conclusion(How to use wsdl?)

EX: How to use Google API with WSDL ? Google provide standard wsdl file http://api.google.com/GoogleSearch.wsdl How to use wsdl file? Many programming languages now understand WSDL and can use this file to automatically invoke Google's API. For example, the WSDL can be imported into .NET, converted into Java code using Apache Axis WSDL2Java, or used directly by Perl SOAP::Lite. The WSDL file has been tested with SOAP::Lite 0.52, the .NET Framework, (via "Add Web Reference" or wsdl.exe version 1.0.3705.0), and Apache Axis Beta 1.

Page 34: WSDL-Web Service Description Language

How to use wsdl?

Use Google with Perl Example : use SOAP::Lite; my $key='000000000000000000000000'; my $query="foo"; my $googleSearch = SOAP::Lite -> service("file:GoogleSearch.wsdl"); my $result = $googleSearch -> doGoogleSearch($key, $query, 0, 10, "false", "", "false", "", "latin1", "latin1"); print "About $result->{'estimatedTotalResultsCount'} results.\

n";

Page 35: WSDL-Web Service Description Language

How to use wsdl?

What is SOAP::Lite ? SOAP::Lite makes the request for service

description, parses it, builds the stub (object that make available the same methods as remote service) and returns it to you.

Page 36: WSDL-Web Service Description Language

How to use wsdl?

Example : #!perl -w use SOAP::Lite; my $service = SOAP::Lite -> service(‘http://api.google.com/GoogleSearch.wsdl'); print ‘ReturnByMSFT + ReturnByORCL = ', $service->getQuote(‘ReturnByMSFT') + $service->getQuote(‘ReturnByORCL');

Page 37: WSDL-Web Service Description Language

How to use wsdl?

You may also use your local computer with multiple wsdl file ..

Example : #!perl -w use SOAP::Lite service

=>’http://api.google.com/GoogleSearch.wsdl ', #service=>'file:/your/local/path/GoogleLocal.wsdl‘, # service => 'file:./yourOwnService.wsdl', ; print getQuote(‘RetrunByMSFT'), "\n";More Detail please check : http://www.soaplite.com/

Page 38: WSDL-Web Service Description Language

References

Web Services Description Language (WSDL) 1.1W3C Note 15 March 2001 : [http://www.w3.org/TR/2001/NOTE-wsdl-20010315 ]Web Services Description Language (WSDL) Version 1.2 Part 1: Core LanguageW3C Working Draft 11 June 2003[http://www.w3.org/TR/2003/WD-wsdl12-20030611 ]Web service :[http://ru.sun.com/win/developers/std02/presentations/ritter3.pdf]WSDL overview:[http://www.intl-interfaces.com/servicemodel/WSDLOverview1.pdf]Web Service Web Service Description Language [www.ti5.tu-harburg.de/Lecture/03ss/SEM/030505/ 030505MariuszChechelski_slides.pdf ]SOAP::Lite for Perl [http://www.soaplite.com/ ]Google API package readme.txt [http://www.google.com/apis/download.html]