2007-09-19 22:09 Category: Web Service prev | Post Author Juxtapose | Comments | Trackback (0) | PermalinkThe WSDL (Web services Description language,web Service Description Language) is an XML application that defines a Web service description as a set of service access points, These service access points allow clients to access services that contain document-oriented information or process-oriented calls (similar to remote procedure calls). The WSDL first describes the operation that is accessed and the request/Response message used at access, and then binds it to the specific transport protocol and message format to ultimately define the specific deployed service access point. The associated specific deployed service access points become abstract Web services by combining them. This article will explain in detail the structure of the WSDL document and analyze the role of each element.
The WSDL (Web services Description language,web Service Description Language) is an XML application that defines a Web service description as a set of service access points, These service access points allow clients to access services that contain document-oriented information or process-oriented calls (similar to remote procedure calls). The WSDL first describes the operation that is accessed and the request/Response message used at access, and then binds it to the specific transport protocol and message format to ultimately define the specific deployed service access point. The associated specific deployed service access points become abstract Web services by combining them. This article will explain in detail the structure of the WSDL document and analyze the role of each element.
One: WSDL definition
WSDL is a document that accurately describes a Web service, and the WSDL document is an XML document that follows the WSDL XML schema. A WSDL document defines a Web service as a collection of service access points or ports. In WSDL, because the abstract definition of a service access point and message has been detached from a specific service deployment or data format binding, the abstract definition can be reused: a message, an abstract description of the interchange data, and a port type that refers to an abstract collection of operations. Specific protocols and data format specifications for a specific port type form the bindings that can be reused. The Web Access address is associated with a binding that can be reused, a port can be defined, and a collection of ports is defined as a service.
A WSDL document typically contains 7 important elements, the types, import, message, PortType, operation, binding, and service elements. These elements are nested within the definitions element, and definitions is the root element of the WSDL document. The basic structure of the WSDL is described in detail in the next section of the article.
II: The basic structure of WSDL--Overview
As the first section concludes, a basic WSDL document contains 7 important elements. These elements and their roles are described in the following sections.
The WSDL document uses the following elements in the definition of a Web service: Types -a container for a data type definition that uses a type system (typically using a type system in XML schemas). message -Abstract typed definition of the data structure of the communication message. Use the type defined by types to define the data structure of the entire message. Operation -An abstract description of the operations supported in the service, typically a single operation describes a request/response message pair for an access portal. PortType -an abstract collection of operations supported by an access entry point type that can be supported by one or more service access points. Binding-the specific protocol and data format specification bindings for a specific port type. Port -defines a single service access point for which the Protocol/data format binding is combined with a specific Web access address. A collection of service-related access points.
You can refer to the following diagram to understand the WSDL Document Map:
The XML schema of the WSDL can be referenced by the following URLs: http://schemas.xmlsoap.org/wsdl/
Three: The basic structure of WSDL--details
This section describes in detail the role of each element of a WSDL document through an example. The following example is the content of a simple WSDL document, which can be found in one of my other articles: Xfire Development Example--helloworld.
A simple Web service WSDL document that supports the only operation named SayHello, which is implemented by running the SOAP protocol on HTTP. The request accepts a string name, which is processed to return a simple string. The document is as follows: <? XML version= "1.0" encoding= "UTF-8"?>
< wsdl:definitions
targetnamespace = "Http://com.liuxiang.xfireDemo/HelloService"
Xmlns:tns = "Http://com.liuxiang.xfireDemo/HelloService"
Xmlns:wsdlsoap = "http://schemas.xmlsoap.org/wsdl/soap/"
XMLNS:SOAP12 = "Http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd = "Http://www.w3.org/2001/XMLSchema"
XMLNS:SOAPENC11 = "http://schemas.xmlsoap.org/soap/encoding/"
XMLNS:SOAPENC12 = "Http://www.w3.org/2003/05/soap-encoding"
XMLNS:SOAP11 = "http://schemas.xmlsoap.org/soap/envelope/"
XMLNS:WSDL = "http://schemas.xmlsoap.org/wsdl/" >
< Wsdl:types >
< Xsd:schema xmlns:xsd = "Http://www.w3.org/2001/XMLSchema"
attributeFormDefault = "qualified" elementFormDefault = "qualified"
targetnamespace = "Http://com.liuxiang.xfireDemo/HelloService" >
< xsd:element name = "SayHello" >
< Xsd:complextype >
< xsd:sequence >
< xsd:element maxOccurs = "1" minOccurs = "1"
Name = "name" nillable = "true" type = "xsd:string"/>
</xsd:sequence >
</Xsd:complextype >
</xsd:element >
< xsd:element name = "Sayhelloresponse" >
< Xsd:complextype >
< xsd:sequence >
< xsd:element maxOccurs = "1" minOccurs = "1"
Name = "Out" nillable = "true" type = "xsd:string"/>
</xsd:sequence >
</Xsd:complextype >
</xsd:element >
</Xsd:schema >
</wsdl:types >
< wsdl:message name = "Sayhelloresponse" >
< Wsdl:part name = "Parameters" element = "Tns:sayhelloresponse"/>
</wsdl:message >
< wsdl:message name = "Sayhellorequest" >
< Wsdl:part name = "Parameters" element = "Tns:sayhello"/>
</wsdl:message >
< Wsdl:porttype name = "Helloserviceporttype" >
< wsdl:operation name = "SayHello" >
< Wsdl:input name = "Sayhellorequest"
message = "Tns:sayhellorequest"/>
< Wsdl:output name = "Sayhelloresponse"
message = "Tns:sayhelloresponse"/>
</wsdl:operation >
</Wsdl:porttype >
< wsdl:binding name = "Helloservicehttpbinding"
Type = "Tns:helloserviceporttype" >
< Wsdlsoap:binding style = "Document"
Transport = "Http://schemas.xmlsoap.org/soap/http"/>
< wsdl:operation name = "SayHello" >
< wsdlsoap:operation soapaction = ""/>
< Wsdl:input name = "Sayhellorequest" >
< wsdlsoap:body use = "literal"/>
</wsdl:input >
< Wsdl:output name = "Sayhelloresponse" >
< wsdlsoap:body use = "literal"/>
</wsdl:output >
</wsdl:operation >
</wsdl:binding >
< Wsdl:service name = "HelloService" >
< Wsdl:port name = "Helloservicehttpport"
binding = "Tns:helloservicehttpbinding" >
< wsdlsoap:address
Location = "Http://localhost:8080/xfire/services/HelloService"/>
</Wsdl:port >
</Wsdl:service >
</wsdl:definitions >
The ♦types element declares complex data types and elements used in other locations in the WSDL document using the XML Schema language;
The ♦import element is similar to the import element in an XML Schema document and is used to import WSDL definitions from other WSDL documents;
The ♦message element describes the payload of the message using the built-in type, complex type, or element of the XML schema defined in the type element of the WSDL document or in an external WSDL document referenced in the import element;
The ♦porttype element and the operation element describe the interface of the Web service and define his method. The porttype element and the operation element are similar to the method declarations defined in the Java interfaces and interfaces. The operation element uses one or more message types to define the payload of his input and output;
The ♦binding element assigns the porttype element and the operation element to a special protocol and encoding style;
The ♦service element is responsible for assigning an Internet address to a specific binding;
1. Definitions Elements
The root elements of all WSDL documents are definitions elements. The element encapsulates the entire document and provides a WSDL document through its name. In addition to providing a namespace, the element has no other effect and is not described in detail.
The following code is the structure of a definitions element: < Wsdl:definitions
targetnamespace = "Http://com.liuxiang.xfireDemo/HelloService"
Xmlns:tns = "Http://com.liuxiang.xfireDemo/HelloService"
Xmlns:wsdlsoap = "http://schemas.xmlsoap.org/wsdl/soap/"
XMLNS:SOAP12 = "Http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd = "Http://www.w3.org/2001/XMLSchema"
XMLNS:SOAPENC11 = "http://schemas.xmlsoap.org/soap/encoding/"
XMLNS:SOAPENC12 = "Http://www.w3.org/2003/05/soap-encoding"
XMLNS:SOAP11 = "http://schemas.xmlsoap.org/soap/envelope/"
XMLNS:WSDL = "http://schemas.xmlsoap.org/wsdl/" >
</wsdl:definitions >
2. Types elements
WSDL uses the built-in XML Schema type as its basic type system. The types element is used as a container for defining various data types that are not described in the XML Schema built-in types. When the payload of the message part is declared, the message definition uses the data types and elements defined in the types element. The types definition in the WSDL document of this article:
< Wsdl:types >
< Xsd:schema xmlns:xsd = "Http://www.w3.org/2001/XMLSchema"
attributeFormDefault = "qualified" elementFormDefault = "qualified"
targetnamespace = "Http://com.liuxiang.xfireDemo/HelloService" >
< xsd:element name = "SayHello" >
< Xsd:co