Download presentation
Presentation is loading. Please wait.
Published byGiles Webb Modified over 9 years ago
1
1 WSDL Tutorial Heather Kreger (borrowed from Peter Brittenham) Web Services Architect IBM Emerging Technologies
2
2 WSDL: Web Service Description Language Standard for describing Web services Abstract interface for defining operations and their messages Messages contain either document-oriented or procedure- oriented information Bindings to message formats and protocols Defines how to locate the endpoint for the service Example: URLs for HTTP Extensible (SOAP and HTTP extensions are defined) Written in XML, leverages XML schema WSDL V1.1 Specification http://www.w3.org/TR/wsdl
3
3 Usage Scenarios As IDL (Interface Definition Language) Allows tools to generate client access code for a service Examples: IBM WebSphere Studio Application Developer, IBM Web Services Toolkit Standardized service interface descriptions Allows advertisement and dynamic discovery of services Enables dynamic binding to service Complements UDDI registry
4
4 Document Content Abstract Definitions data type definitions operation parameters operation definitions Concrete Definitions operation bindings location/address for each binding Also: used to reference other XML documents
5
5 WSDL Extensibility Elements Extensibility elements can be specified within these WSDL elements: / / / Binding extensibility defined in the specification for: SOAP HTTP MIME
6
6 Document Structure [SOAP] [Request] [data] [Response] [EJB] […] Service(s) Supported Protocol(s) Java class method SOAP Request/ response
7
7 SOAP Binding - RPC Style Indicates that the Web service is accessed using SOAP V1.1 protocol Use style="rpc" attribute on SOAP binding element Example SOAP service method signature: public float getQuote (String symbol)
8
8 Example: Stock Quote Service [1] <definitions name="StockQuoteService" targetNamespace="http://tempuri.org/StockQuoteService“ xmlns:tns="http://tempuri.org/StockQuoteService" …>... public float getQuote (String symbol)
9
9 Example: Stock Quote Service [2]... <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <soap:body use="encoded" namespace="http://tempuri.org/live-stock-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>...
10
10 Example: Stock Quote Service [3] … Stock Quote Service -- <soap:address location="http://tempuri.org/services/StockQuoteService" />
11
11 Message Defines the messages that are referenced in the input, output, and fault elements within an operation A message may have one or more parts Each part contains a reference to a data type elementReference to XML Schema element using a QName typeReference to XML Schema simpleType or complexType *
12
12 PortType Contains one or more abstract operations Each operation references one or more messages Four operation types: One-waySend message to service and there is no response Request-responseSend message to service which returns a correlated message Solicit-responseService sends a message and requestor returns a correlated message NotificationService sends a message to the requestor
13
13 PortType One-way Operation Request-response Operation * * *
14
14 Binding Each binding has an unique name Referenced by a port element Contains a reference to one portType Binding interpreted based on ext. elements * ? ? * *
15
15 Service A WSDL document may contain one or more service elements Each service element may contain one or more ports A port is named, references one binding, and contains the endpoint for the Web service Port names must be unique within a service element Endpoint is specified using an extensibility element *
16
16 Complex Type Definitions Complex data types Defined within the element or by referencing an external XML schema document AddressBook Example: public void addEntry(String name, Address address)...
17
17 AddressBook Service <import location="http://localhost:8080/schema/AddressBook.xsd" namespace="http://tempuri.org/AddressBook”/> </portType...
18
18 SOAP Binding - Document Style Similar to SOAP Binding with RPC Style SOAP binding contains style=“document” attribute This style can also be set on a SOAP body element which is specified with each operation element Used with Web services that specify XML documents for message content Example: UDDI Registry Business Name
19
19 WSDL for UDDI Registry [1] <definitions targetNamespace="urn:uddi-org:inquiry" xmlns:uddi="urn:uddi-org:api_v2" xmlns:tns="urn:uddi-org:inquiry_v2"...> <import namespace="urn:uddi-org:api" location="http://www.uddi.org/schema/uddi_v2.xsd" />......
20
20 WSDL for UDDI Registry [2] <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <soap:body use="literal" parts="body" namespace="urn:uddi-org:api_v2" />...
21
21 MIME Binding Examples of supported MIME types: multipart/related text/xml application/x-www-form-urlencoded Input or output message can be defined using MIME binding MIME binding can be combined with SOAP binding to define a service that uses SOAP attachments Use multipart/related binding SOAP envelope must be in the root part Define other parts using MIME binding
22
22 Attachment Service Interface [1]...
23
23 Attachment Service Interface [2]...
24
24 Attachment Service Interface [3] <soap:body parts="fileList" use="encoded" namespace="http://tempuri.org/attachment-service" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <soap:body use="encoded“ namespace=“http://tempuri.org/attachment-service" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
25
25 WSDL4J WSDL Java API WSDL object model Parse contents of a WSDL document Programmatically create new WSDL documents Open source project on IBM developerWorks site http://oss.software.ibm.com/developerworks/projects/wsdl4j/ Will be a reference implementation for JSR 110 Primarily a set of Java interfaces that can be implemented by anyone Java package name: javax.wsdl
26
26 WSDL4J Example - Find Port // Get WSDLReader WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); // Read WSDL service implementation document Definition wsdlDefinition = wsdlReader.readWSDL(null, wsdlURL); // Get the service elements Map services = definition.getServices(); // Get an iterator for the list of services Iterator serviceIterator = services.values().iterator(); boolean bPortFound = false; while ((serviceIterator.hasNext()) && !(bPortFound)) { // Get next service element Service service = (Service) serviceIterator.next(); // Determine if this service element contains the specified port if ((port = service.getPort(portName)) != null) bPortFound = true; }
27
27 WSDL Resources WSDL V1.1 Specification http://www.w3.org/TR/wsdl W3C Web Services Description Working Group http://www.w3c.org/2002/ws/desc/ WSDL4J Open Source Project http://oss.software.ibm.com/developerworks/projects/ wsdl4j/ Yahoo Group: wsdl http://groups.yahoo.com/group/wsdl
28
28 An Overview of Web Services – Part 2 Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.