Web Services, Part I: Introduction: Writing WSDL - Doc JavaScript
Web Services, Part I: Introduction
Writing WSDL
The WSDL document can be divided into two groups: the Abstract Definitions Group and the Concrete Descriptions Group. The abstract sections define SOAP messages in a platform- and language-independent manner; they don't contain any machine- or language-specific elements. The concrete sections are site-specific, machine-specific, or language-specific. The abstract elements are types
, message
, and portType
. The concrete elements are binding
and service
.
The root of any service description file is the <definitions>
element. The <definitions>
elements includes the namespace definitions. In the Weather - Temperature Web service, it looks like this:
<definitions name="TemperatureService" targetNamespace=" https://www.xmethods.net/sd/TemperatureService.wsdl" xmlns:tns=" https://www.xmethods.net/sd/TemperatureService.wsdl" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/" xmlns="https://schemas.xmlsoap.org/wsdl/">
The types
element contains datatype definitions. Usually, this element includes a schema
element that defines various datatypes. Here is a complexType
element definition from the interopTest
Web service's types
element:
<types> <schema xmlns="https://www.w3.org/2001/XMLSchema" targetNamespace="https://soapinterop.org/xsd"> <complexType name="ArrayOfstring"> <complexContent> <restriction base="SOAP-ENC:Array"> <sequence> <element name="item" type="string" maxOccurs="unbounded" /> </sequence> <attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="string[]" /> </restriction> </complexContent> </complexType> </schema> </types>
The message
element describes the data being exchanged between the Web service providers and consumers. Each Web method has two messages: input and output. The input describes the parameters for the Web method; the output describes the return data from the Web method. Each message contains zero or more <part>
parameters, one for each parameter of the Web method. Each parameter associates with a concrete type defined in the <types>
container element. In the Temperature - Weather Web service, the input parameter is a string-typed zip code. Here is how the <message>
element is defined:
<message name="getTempRequest"> <part name="zipcode" type="xsd:string"/> </message>
The portType
element includes a supported set of operations. Each operation includes the input and the output messages of the operation. Here is the getTemp
operation from the Temperature - Weather Web service:
<portType name="TemperaturePortType"> <operation name="getTemp"> <input message="tns:getTempRequest" /> <output message="tns:getTempResponse" /> </operation> </portType>
Each binding
element describes a supported protocol. Similar to the portType
element, the binding
element includes supported operations, as well as the input and output for each operation. Here is the binding
element from the Temperature - Weather Web service:
<binding name="TemperatureBinding" type="tns:TemperaturePortType"> <soap:binding style="rpc" transport=" https://schemas.xmlsoap.org/soap/http" /> <operation name="getTemp"> <soap:operation soapAction="" /> <input> <soap:body use="encoded" namespace="urn:xmethods-Temperature" encodingStyle="https://schemas.xmlsoap.org/soap/encoding/" /> </input> <output> <soap:body use="encoded" namespace="urn:xmethods-Temperature" encodingStyle="https://schemas.xmlsoap.org/soap/encoding/" /> </output> </operation> </binding>
The service
element is a collection of ports
. Each port
supports a different protocol. Here is a SOAP port from the Temperature -- Weather Web service:
<service name="TemperatureService"> <documentation>Returns current temperature in a given U.S. zipcode</documentation> <port name="TemperaturePort" binding="tns:TemperatureBinding"> <soap:address location="https://services.xmethods.net:80/soap/ servlet/rpcrouter" /> </port> </service>
Next: A Final Word
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 5, 2001
Revised: November 5, 2001
URL: https://www.webreference.com/js/column96/10.html