Presentation is loading. Please wait.

Presentation is loading. Please wait.

WSDL Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

Similar presentations


Presentation on theme: "WSDL Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."— Presentation transcript:

1 WSDL Kanda Runapongsa (krunapon@kku.ac.th)krunapon@kku.ac.th Dept. of Computer Engineering Khon Kaen University

2 168493: XML and Web Services (II/2546) 2 What is WSDL? WSDL: Web Services Description Language A document format for precisely describing Web services A WSDL document tells us how to use a Web service

3 168493: XML and Web Services (II/2546) 3 A WSDL Code Generator WSDL is well suited for code generators, which can read a WSDL document and generate a programmatic interface for accessing a Web service Example: a JAX-RPC provider uses WSDL 1.1 to generate Java RMI interfaces and network stubs, which can be used to exchange SOAP messages with a Web service

4 168493: XML and Web Services (II/2546) 4 A WSDL Code Generator JAX-RPC is not the only technology that can generate interfaces and network stubs from WSDL document There are many other code generators, including tools in Microsoft.NET Apace Axis

5 168493: XML and Web Services (II/2546) 5 A WSDL Code Generator A JAX-RPC toolkit would use a WSDL document to generate a Java RMI interface (an endpoint interface) and a networking stub that implements the interface What is Java RMI?

6 168493: XML and Web Services (II/2546) 6 JAVA RMI RMI: Remote Method Invocation Java-based technology which allows Java programs to access the objects of another Java program running on a different computer RMI is a relatively simple protocol, but unlike more complex protocols such as CORBA and DCOM, it works only with Java objects

7 168493: XML and Web Services (II/2546) 7 Main Pieces of Info in WSDL WSDL definition contains four important pieces of information about the Web service Interface information describing all the publicly available functions Data type information for the incoming (request) and outgoing (response) message to these functions

8 168493: XML and Web Services (II/2546) 8 Main Pieces of Info in WSDL Two other important pieces of information about the Web service Binding information about the protocol to be used for invoking the specified Web service Address information for locating the specified Web service

9 168493: XML and Web Services (II/2546) 9 A WSDL Document A WSDL document contains seven important elements types import message portType operations binding service These elements are nested in definitions element

10 168493: XML and Web Services (II/2546) 10 WSDL Important Elements types Use the XML schema language to declare complex data types and elements that are used elsewhere in the WSDL document import Similar to an import element in an XML schema document; it’s used to import WSDL definitions from other WSDL documents

11 168493: XML and Web Services (II/2546) 11 WSDL Important Elements message Describe the message’s payload using XML schema built-in types Complex types, or elements that are defined in the WSDL document’s types elements Elements defined in an external WSDL document the import element refers to

12 168493: XML and Web Services (II/2546) 12 WSDL Important Elements portType and operation Describe a Web service’s interface and define its methods A portType and its operation elements are analogous to a Java interface and its method declarations An operation element uses one or more message types to define its input and output payloads

13 168493: XML and Web Services (II/2546) 13 WSDL Important Elements binding Assign a portType and its operation to a particular protocol (for instance, SOAP 1.1) and encoding style service Responsible for assigning an Internet address to a specific binding

14 168493: XML and Web Services (II/2546) 14 WSDL Declarations The XML Declaration The XML declaration in the sample WSDL document specified a character encoding of UTF-8 A WSDL document must use either UTF- 8 or UTF-16 encoding; other encoding systems are not allowed

15 168493: XML and Web Services (II/2546) 15 The definitions Element The root element of all WSDL elements is the definitions element <definitions name=“BookQuoteWS” targetNamespace=“http://www.Monson- Haefel.com/jwsbook/BookQuote”http://www.Monson- Haefel.com/jwsbook/BookQuote xmlns:mh=“http://www.Monson- Haefel.com/jwsbook/BookQuote” xmlns:soapbind=“http://schemas.xmlsoap.org/ws dl/soap/”http://schemas.xmlsoap.org/ws dl/soap/ xmlns:xsd=“http://www.w3.org/2001/XMLSchem a”http://www.w3.org/2001/XMLSchem a xmlns=“http://schemas.xmlsoap.org/wsdl/”>http://schemas.xmlsoap.org/wsdl/

16 168493: XML and Web Services (II/2546) 16 The types Element WSDL adopts the W3C XML schema built- in types The types element serves as a container for defining any data types that are not described by the XML schema built-in types The data types and elements defined in types element are used by message definitions

17 168493: XML and Web Services (II/2546) 17 <definitions … xmlns:mh=http://abc.com/BQuote”http://abc.com/BQuote xmlns=“http://schemas.xmlsoap.org/wsdl”/> http://abc.com/BQuote … … Using Types Defined in the WSDL types

18 168493: XML and Web Services (II/2546) 18 The import Element The import element makes available in the present WSDL document the definition from a specified namespace in another WSDL document Example, your company may want to maintain WSDL documents for shipping and order processing separately, but present a complete definition of all Web services in a public directory accessible by business partners

19 168493: XML and Web Services (II/2546) 19 The import Element Example <definitions name=“AllMhWebServices” xmlns=“http://schemas.xmlsoap.org/wsdl/”>http://schemas.xmlsoap.org/wsdl/ http://www.mh.com/jwsbook/BookQuotehttp://www.mh.com/jwsbook/BookPrice.wsdl http://www.mh.com/jwsbook/pohttp://www.mh.com/jwsbook/PurchaseOrder. wsdl <import namespace=“http://www.mh.com/jwsbook/shipping”http://www.mh.com/jwsbook/shipping location=“http://www.mh.com/jwsbook/wsdl/Shipping.w sdl”/>http://www.mh.com/jwsbook/wsdl/Shipping.w sdl

20 168493: XML and Web Services (II/2546) 20 The message Element The message element describes the payload of a message used by a Web service The way to define a message element depends on whether you use RPC-style or document-style messaging

21 168493: XML and Web Services (II/2546) 21 The message Element for RPC-Style <message name=“GetBookPriceResponse”>

22 168493: XML and Web Services (II/2546) 22 The message Element for Document-Style http://www.mh.com/jwsbook/PO http://www.mh.com/jwsbook/PO http://www.mh.com/jwsbook/POhttp://www.mh.com/jwsbook/po.xsd

23 168493: XML and Web Services (II/2546) 23 The portType Element A portType element defines the abstract interface of a Web service It’s a lot like a Java interface because it defines an abstract type and its method, but not an implementation In WSDL, the portType is implemented by the binding and service elements

24 168493: XML and Web Services (II/2546) 24 portType and Java Interface portType Java Interface public interface bookQuote { public float getBookPrice(String isbn); }

25 168493: XML and Web Services (II/2546) 25 The operation Element The “methods” of the portType are its operation elements A portType may have one or more operation elements, each of which defines an RPC- or document-style Web service method Each operation is composed of input, output, and fault elements

26 168493: XML and Web Services (II/2546) 26 The operation Element Example

27 168493: XML and Web Services (II/2546) 27 Parameter Order within an Operation … …

28 168493: XML and Web Services (II/2546) 28 The binding Element The binding element maps an abstract portType to a set of concrete protocols such as SOAP and HTTP, messaging styles (RPC or document), and encoding styles (Literal or SOAP Encoding) The binding element and its subelements are used in combination with protocol-specific elements

29 168493: XML and Web Services (II/2546) 29 The binding Element http://schemas.xmlsoap.org/wsdl/ …

30 168493: XML and Web Services (II/2546) 30 The binding Element http://schemas.xmlsoap.o rg/wsdl/ http://schemas.xmlsoap.org/soa p/http

31 168493: XML and Web Services (II/2546) 31 The binding Element <soapbind:operation style=“rpc” soapAction=“http://www.mh.com/jwsb ook/BookQuote/GetBookPrice”/>http://www.mh.com/jwsb ook/BookQuote/GetBookPrice http://www.mh.com/jwsboo k/BookQuote

32 168493: XML and Web Services (II/2546) 32 The service and port Elements The service element contains one or more port elements, each of which represents a different Web service The port element assigns the URL to a specific binding A service may have more than one port element, each of which assigns a URL to a specific binding

33 168493: XML and Web Services (II/2546) 33 Defining a service Element http://www.mh.com/jws book/BookQuote


Download ppt "WSDL Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."

Similar presentations


Ads by Google