Download - WSDL : Web Service Definition Language
WSDL : Web Service Definition Language
Dr. Yuhong YanNRC-IIT-Fredericton
Internet logic
WSDL: describe a web services
• Initialized by IBM, Microsoft, Ariba and 6~ other companies
• 2004.8: w3c releases WSDL 2.0
Interoperability Using WSDL
Get WSDL docInvoke Service
J2EE ContainerService Objects
WSDL description
Client
Service
Service
SOAP
HTTP
WSDL: Describe a web service
• Interface information describing all publicly available functions
• Data type information for all message requests and message responses
• Binding information about the transport protocol to be used
• Address information for locating the specified services
WSDL:
• A contract between requestor and provider• Platform and language-independent• Describe SOAP services• Automatic tool to generate client and sever code
What do we learn?
• WSDL specification• Generate WSDL for a service (from java objects
to WSDL)• Generate java classes from WSDL• Other ways for distributed system: rmi, and
CORBA
An example of WSDL: HelloWorld
<wsdl:definitions targetNamespace="http://localhost:8080/axis/services/urn:HelloWorld" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/services/urn:HelloWorld" xmlns:intf="http://localhost:8080/axis/services/urn:HelloWorld" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://www.w3.org/1999/XMLSchema" xmlns:tns2="http://www.w3.org/2003/05/soap-encoding" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Root element, defines namespaces
WSDL-SOAP binding
xmlschema
WSDL schema
Convention, refer to itself (?)WSDL uses it to generate package name
<Service>
<wsdl:service name="HelloWorldServiceService"> <wsdl:port
binding="impl:urn:HelloWorldSoapBinding" name="urn:HelloWorld">
<wsdlsoap:address location="http://localhost:8080/axis/services/urn:HelloWorld" />
</wsdl:port></wsdl:service>
Where is the service located?
The service location: the endpoint of the SOAP message
<Binding>
<wsdl:binding name="urn:HelloWorldSoapBinding" type="impl:HelloWorldService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="sayHello"> <wsdlsoap:operation soapAction="" /> - <wsdl:input name="sayHelloRequest"> <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://HelloWorld.samples" use="encoded" />
</wsdl:input>- <wsdl:output name="sayHelloResponse"> <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/urn:HelloWorld" use="encoded" />
</wsdl:output> </wsdl:operation>- </wsdl:binding>
Bind messages to operationsUse SOAP HTTP protocol
<portType>
<wsdl:portType name="HelloWorldService">- <wsdl:operation name="sayHello"
parameterOrder="in0 in1"> <wsdl:input message="impl:sayHelloRequest"
name="sayHelloRequest" /> <wsdl:output
message="impl:sayHelloResponse" name="sayHelloResponse" />
</wsdl:operation></wsdl:portType>
Bind messages to operations
Operation: sayHello
Input Message: sayHelloRequest
Output Message: sayHelloResponse
<message>
<wsdl:message name="sayHelloRequest"> <wsdl:part name="in0" type="tns2:string" /> <wsdl:part name="in1" type="tns2:string" /> </wsdl:message><wsdl:message name="sayHelloResponse"> <wsdl:part name="sayHelloReturn"
type="tns2:string" /> </wsdl:message>
Define message: sayHelloRequestContent of message
Define massage: sayHelloResponse
Parameter 1, type stringParameter 2, type string
Parameter 1, type string
Structure of WSDL
P121 fig 6-1
<definitions>:Root WSDL Element
<types>:What data types will be transmitted?
<message>:What message will be transmitted?
<portType>:What operations (functions) will be supported?
<binding>:How will the messages be transmitted on the wire?What SOAP-specific details are there?
<service>:Where is the service located?
Definition: <wsdl:definitions>
• Root element• Name of the web service• Declare multiple namespaces
Complex data types: <types>
• Not used if limit to XML schema• Define complex types (correspondent to a class
in java)
Message definitions: <message>
• A request message or a response message• Name of the message• Element <part> defines the data types used in the
message• Types of the parameters for the request message• Types of the return values for the response
message
Operation definitions: <portType>
• Operations: the remote methods• Input/output messages for operations
<wsdl:portType name="HelloWorldService">- <wsdl:operation name="sayHello" parameterOrder="in0
in1"> <wsdl:input message="impl:sayHelloRequest"
name="sayHelloRequest" /> <wsdl:output message="impl:sayHelloResponse"
name="sayHelloResponse" /> </wsdl:operation></wsdl:portType>
Operation patterns supported by WSDL 1.1
P126. fig 6-3
Client
One-way
Request-response
Client
Client
Client
Solicit-response
Notification
Service<input>
Service
Service
Service
<input>
<output>
<output>
<input>
<output>
1
1
2
2
Basic patterns of operation
• One-way: – The service receives a message. – The operation therefore has a single input
element• Request-response:
– The service receives a message and sends a response
– One input element, one output element
Basic patterns of operation (2)
• Solicit-response– The service sends a message and receives a
response– The operation has one output message,
followed by one input message• Notification
– The service sends a message. – The operation has one output message
Transmission protocols: <binding>
• Binding transmission protocols to operations• Axis: http
Service location: <service>
• SOAP endpoint of the web service
Second example: WSDL of StockQuote
• Deploy the sample StockQuoteService• The WSDL is at
http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes?wsdl
Messages
<wsdl:message name="getQuoteRequest"> <wsdl:part name="symbol" type="tns2:string" /> </wsdl:message><wsdl:message name="getQuoteResponse"> <wsdl:part name="getQuoteReturn"
type="xsd:float" /> </wsdl:message>
Operations
<wsdl:portType name="StockQuoteService">- <wsdl:operation name="getQuote"
parameterOrder="symbol"> <wsdl:input message="impl:getQuoteRequest"
name="getQuoteRequest" /> <wsdl:output message="impl:getQuoteResponse"
name="getQuoteResponse" /> </wsdl:operation></wsdl:portType>
Binding
<wsdl:binding name="GetQuoteSoapBinding" type="impl:StockQuoteService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getQuote"> <wsdlsoap:operation soapAction="" /> - <wsdl:input name="getQuoteRequest"> <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://stock.samples" use="encoded" />
</wsdl:input>- <wsdl:output name="getQuoteResponse"> <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes" use="encoded" />
</wsdl:output> </wsdl:operation> </wsdl:binding>
Service location
<wsdl:service name="StockQuoteServiceService">- <wsdl:port binding="impl:GetQuoteSoapBinding"
name="GetQuote"> <wsdlsoap:address
location="http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes" />
</wsdl:port> </wsdl:service>
WSDL Summary
<definitions>:The StockQuoteService
<message>:1) getQuoteRequest: parameter:symbol; type: string2) getQuoteResponse: return float
<portType>:getQuote operation that consists of a request/response service
<binding>:Direction to use the SOAP HTTP transport protocol.
<service>:Service available at: localhost:8080/axis/services/urn:xmltoday-delayed-quotes
Using WSDL with Axis
• Obtaining WSDL for deployed services• WSDL2Java: Building stubs, skeletons, and data• Java2WSDL: Building WSDL from Java
Obtain WSDL for deployed services
• Axis generates WSDL for any deployed services• In the service list, check the WSDL files