Web Services Description Language (WSDL)
WSDL is an XML format for describing network services. The service is viewed as a set of endpoints (or ports) operating on messages that may be either document oriented or procedure-oriented.
The operations and procedures are described abstractly and then bound to specific network protocols and message formats.
The WSDL 1.1 Note illustrates binding to SOAP 1.1, HTTP, and MIME. This note was contributed to the W3C by Ariba, IBM, and Microsoft in March 2001 and consolidates concepts in earlier proprietary work. The W3C sponsored a Workshop on Web Services in April 2001. The program and minutes of the Workshop are available.
WSDL Elements
WSDL documents use the following elements to define Web services:
WSDL Example
The Note has an example illustrating the general structure with a fixed XML format.
This is an example from the Note with SOAP binding of a call-response RPC using HTTP:
<?xml version="1.0"?>
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="GetTradePriceInput">
<part name="tickerSymbol" element="xsd:string"/>
<part name="time" element="xsd:timeInstant"/>
</message>
<message name="GetTradePriceOutput">
<part name="result" type="xsd:float"/>
</message>
<portType name="StockQuotePortType">
<operation name="GetTradePrice">
<input message="tns:GetTradePriceInput"/>
<output message="tns:GetTradePriceOutput"/>
</operation>
</portType>
<binding name="StockQuoteSoapBinding"
type="tns:StockQuotePortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetTradePrice">
<soap:operation
soapAction="http://example.com/GetTradePrice"/>
<input>
<soap:body use="encoded"
namespace="http://example.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://example.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>>
</binding>
<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://example.com/stockquote"/>
</port>
</service>
</definitions>
WSDL Implementation
The textbook provides an example WSDL implementation. The application provides for four distributed clients submitting invoices to the server. The server replies with a status message confirming submittal or returning an error. SOAP is used for the messages and HTTP is used for communication.
The server is implemented in MS VB. There are four example clients implemented in Java (with Apache SOAP), MS VB, Perl (with SOAP::Lite), and MS WSH. Here is the Perl client, implemented just as a stub with hardcoded values:
#perl
use SOAP::Lite;
# HTTP headers may be needed depending
on environment
print "HTTP/1.0 201 Ok \n";
print "Content-type:text/html\n\n";
# Set parametar variables
$idInvoiceID = "1";
$idCustomerID = "3";
$dtInvoiceDate = "2001-02-08T00:00:00";
$strNotes = "This is an invoice
submitted via the PERL client";
$strDeliveryAddress = "1234 PERL
Street, Some City, AZ 00000";
$strPaymentTerms = "Net 15 days";
$strPaymentReceived = "N";
$strWSDL = "http://localhost/soap/InvoiceSubmit.wsdl";
$strEndPoint = "http://localhost/soap/InvoiceSubmit.asp";
# Print the introductory text
print "<html><body>";
print "<html><head><title>SOAP
Client Using PERL";
print "</title></head><body><h3>SOAP
Client Using PERL</h3>";
print "<h4>Invoice Submitted
to Microsoft SOAP Server.<br><br>";
print "Reply from Microsoft SOAP
Server:</h4>";
# Call the Microsoft SOAP server
and print the result
print SOAP::Lite
-> service($strWSDL)
-> proxy($strEndPoint)
-> InvoiceAdd($idInvoiceID, $idCustomerID, $dtInvoiceDate, $strNotes,
$strDeliveryAddress, $strPaymentTerms, $strPaymentReceived);
print "</body></html> ";
The call to SOAP::Lite makes the
operation very simple. The program just provides the service description
(the WSDL file in InvoiceSubmit.wsdl), the location of the service endpoint
(the URI of the ASP program), and the method being called (InvoiceAdd)
with parameters.