Web Services, Part I: Introduction: Writing WSDL - Doc JavaScript | WebReference

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"

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:

 <schema xmlns="http://www.w3.org/2001/XMLSchema"
  <complexType name="ArrayOfstring">
    <restriction base="SOAP-ENC:Array">
      <element name="item" type="string"
      maxOccurs="unbounded" />
     <attribute ref="SOAP-ENC:arrayType"
     wsdl:arrayType="string[]" />

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"/>

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" />

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="
  http://schemas.xmlsoap.org/soap/http" />
    <operation name="getTemp">
      <soap:operation soapAction="" />
          <soap:body use="encoded" namespace="urn:xmethods-Temperature"
            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
          <soap:body use="encoded" namespace="urn:xmethods-Temperature"
            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />

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.
  <port name="TemperaturePort" binding="tns:TemperatureBinding">
    <soap:address location="http://services.xmethods.net:80/soap/
      servlet/rpcrouter" />

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: http://www.webreference.com/js/column96/10.html