WSDL - 大葉大學

Download Report

Transcript WSDL - 大葉大學

Web Service Description
Language (WSDL)
大葉大學資工系
1
Introduction


WSDL is created by the collaboration of Microsoft
and IBM to standardize the way to describe services.
Properties of WSDL
• Specify the service’s capabilities, location, and
how to access the service
• Define the structure of the messages a service
sends and receives
• Provide specific technical information for
communicating with the service
2
WSDL in Web Service
XML Registry or
WSDL
Repository
2. Retrieve WSDL
document
1. Web service
administrator posts
WSDL document to
XML registry or
WSDL repository
Web
Servic
e
3. Invoke
Client
3
WSDL and Code Generation
4
WSDL Specification

WSDL is an XML grammar for describing web
services. The specification is divided into six major
elements.
<definitions>: Root WSDL element
<types>: What data types will be transmitted?
<message>: What messages 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 service located?
5
types



Provides definitions for the data types that SOAP
messages contain.
All the data types used between the client and server
W3C XML Schema specification is the default choice
<types>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://greath.example.com/2004/schemas/resSvc"
xmlns="http://greath.example.com/2004/schemas/resSvc">
<xs:element name="checkAvailability" type="tCheckAvailability"/>
<xs:complexType name="tCheckAvailability">
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="checkAvailabilityResponse" type="xs:double"/>
<xs:element name="invalidDataError" type="xs:string"/>
</xs:schema>
</types>
6
definitions




The root element of all WSDL documents
Name of the web service
Namespace used in the document
All service elements
<definitions name=“ValidateAddress”
targetNamespace=“http://yourserver/wsdl/”
xmlns:http=“http://schemas.xmlsoap.org/wsdl/http/”
xmlns:mime=“http://schemas.xmlsoap.org/wsdl/mime”
xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/”
/>
7
message



Describe a one-way message, whether is a single
message request or a single message response.
Define name of the message.
Contain zero or more part elements, which can refer
to parameters or return value.
• For the GET or POST <message> tags, each part
must be given a data type (s:string)
• For the SOAP transmission, no data type is
specified. Use the <element> to represent the
structure for the parameter.
8
message
<message name=“ValidateSopaIn”>
<part name=“parameters” element=“Validate” />
</message>
<message name=“ValidatesoapOut”>
<part name=“parameters” element=“ValidateResponse” />
</message>
<message name=“ValidateHttpGetIn”>
<part name=“City” type=“s:string” />
<part name=“State” type=“s:string” />
</message>
<message name=“ValidateHttpGetOut”>
<part name=“Body” element=“boolean” />
</message>
<message name=“ValidateHttpPostIn”>
<part name=“City” type=“s:string” />
<part name=“State” type=“s:string” />
</message>
<message name=“ValidateHttpPostOut”>
<part name=“Body” element=“boolean” />
</message>
9
portType


Combine multiple message elements to form a
complete one-way or round-trip operation.
A portType can define multiple operations.
<portType name=“ValidateSoap”>
<operation name=“Validate”>
<documentation>Validates the city/state/zip code</documentation>
<input message=“ValidateSoapIn” />
<output message=“ValidateSoapOut” />
</operation>
<operation name=“ValidateHttpGet”>
…
</portType>
10
WSDL Specification


binding
• Describe the concrete specifics of how the service
will be implemented on the wire.
service
• Define the address for invoking the specified
service.
11
Example 1

message
• Represent the variables that the clients and Web
services transfer between each other.
• The “part” sub-element specifies the name and
data type of message exchanged.
• name: parameters, element: s0:valid_credit_card
• The types of the messages in the “schema”
element.
<message name="valid_credit_cardSoapIn">
<part name="parameters" element="s0:valid_credit_card" />
</message>
<message name="valid_credit_cardSoapOut">
<part name="parameters" element="s0:valid_credit_cardResponse" />
</message>
12
Example 1

portType
• Contain “operation” elements, which translate the
messages defined in the WSDL “message”
elements to those passed to and from the actual
services.
• Each operation element contains an “input” and
an “output” element, each of which associates a
“message” element.
<portType name="validCCSoap">
<operation name="valid_credit_card">
<input message="s0:valid_credit_cardSoapIn" />
<output message="s0:valid_credit_cardSoapOut" />
</operation>
</portType>
13
Example 1

binding
• The “binding” element specifies how the client
and Web service should send messages to one
another.
<binding name="validCCSoap" type="s0:validCCSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="valid_credit_card">
<soap:operation soapAction="http://tempuri.org/valid_credit_card" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
14
Example 1

service
• Specify the URL that clients use to invoke the
Web service.
• Each “port” sub-element contains a URL for a
unique bidning.
<service name="validCC">
<port name="validCCSoap" binding="s0:validCCSoap">
<soap:address location="http://163.23.24.139/validCC/validCredit.asmx" />
<port>
<service>
15
WSDL Specification


WSDL defines an XML-based grammar for
describing network services as a set of endpoints
that accept messages containing either documentoriented or procedure-oriented information.
Schema:
• WSDL Framework:
http://schemas.xmlsoap.org/wsdl/.
• WSDL SOAP binding:
http://schemas.xmlsoap.org/wsdl/soap/.
• WSDL HTTP GET & POST binding:
http://schemas.xmlsoap.org/wsdl/http/.
• WSDL MIME binding:
http://schemas.xmlsoap.org/wsdl/mime/.
16
Details






Message: References to XML Schemas defining the different
parts of the message (for example, Headers and Body).
Operation: Lists the messages involved in one message flow
of the endpoint. For example, a request-response operation
would refer to two messages.
PortType: The set of message flows (operations) expected by
a particular endpoint type, without any details relating to
transport or encoding.
Binding: The transport and encoding particulars for a portType.
Port: The network address of an endpoint and the binding it
adheres to.
Service: A collection of related endpoints.
17
WSDL Grammar for End Points
18