Home
 

User login

 
 

Navigation

 
 

Events

« July 2008
SunMonTueWedThuFriSat
12345
6789101112
13141516171819
20212223242526
2728293031
 

Simplified WSDL

By James Pasley - 1 June 2003

One of the advantages of WSDL being written in XML is that the syntax is easily processed by applications while still being human readable. However, if you have ever thought that all these XML tags get in the way and longed for a more traditional syntax (as used in many programming languages), then this one line of text is the solution to your problems. Just add the following line of text at the start of your WSDL file, just after the line <?xml version="1.0"?>:

<?xml-stylesheet href="http://www.capescience.com/simplifiedwsdl.xslt" type="text/xsl"?>

So the start of your WSDL file should look like this:

<?xml version="1.0"?>
<?xml-stylesheet href="http://developer.capeclear.com/files/simplifiedwsdl.xslt" type="text/xsl"?>
<wsdl:definitions ....

Now simply open the file using either Internet Explorer 6 or Netscape 6.2 and your WSDL file appears neatly formatted with syntax highlighting, Java style comments and not an XML tag in sight. If you are using a different Web browser, then see the section on converting your WSDL file to HTML.

What does it look like?

Below is a sample taken from the W3C note describing WSDL:

<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote/definitions">
<import namespace=http://example.com/stockquote/schemas
location="http://example.com/stockquote/stockquote.xsd">
</import>
<message name="GetLastTradePriceInput">
<part name="body" element="xsd1:TradePriceRequest">
</part>
</message>
<message name="GetLastTradePriceOutput">
<part name="body" element="xsd1:TradePrice">
</part>
</message>
<portType name="StockQuotePortType">
<operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput">
</input>
<output message="tns:GetLastTradePriceOutput">
</output>
</operation>
</portType>
</definitions>

When you load it into your Web browser it will look as follows:

definitions StockQuote targetNamespace http://example.com/stockquote/definitions
{
import http://example.com/stockquote/schemas from http://example.com/stockquote/schemas
message GetLastTradePriceInput
{
part body element xsd1:TradePriceRequest
}
message GetLastTradePriceOutput
{
part body element xsd1:TradePrice
}
portType StockQuotePortType
{
tns:GetLastTradePriceOutput GetLastTradePrice ( tns:GetLastTradePriceInput )
}
}

If you would still like to see the original WSDL, just click Source on the View menu.

So how does it work?

The line added at the start of the file associates a stylesheet with the WSDL document. This is the standard mechanism for associating stylesheets as described in the W3C recomendation . The stylesheet in this case is an XSL transform which converts the XML into HTML. The Web browsers mentioned above contain XSLT Processors which enable the transformation to be performed automatically as the document is displayed. The HTML generated in turn references a cascading style sheet which provides the font selection and colors.

If you are running Internet Explorer 6 or Netscape 6.2, you can see this transformation in action by viewing this file: stockquoteSOAP.wsdl

What if I don't like the format?

As this is just a combination of an XSL transform and cascading style sheet, it is quite simple to modify. If you would like to change either the colors or fonts, then modify the CSS file. Any changes to the contents of what is displayed requires changes to the XSLT. If your familiar with XSLT, you will find the transformation rules used here easy to modify. If not, then in my next article I will explain each rule and give XSLT the same treatment, making it just as easy to read.

Converting WSDL to HTML

Only the latest generation of Web browsers include XSLT processors. However, if you would like to display this format to a wider audience, then it is a better idea to do the transformation on the server side and publish the resulting HTML. There are any number of XSLT processors which will do this. You can find a list of them at http://dmoz.org/Computers/Data_Formats/Markup_Languages/XML/Style_Sheets/XSL/Implementations/.

A good one to start with is Saxon, available from http://saxon.sourceforge.net/. Once you have installed it, download the stylesheet from CapeScience and save it as simplifiedwsdl.xslt, then use the following command line to convert your WSDL file to HTML:

saxon -o mywsdl.html mywsdl.wsdl simplifiedwsdl.xslt

The resulting HTML file may be viewed using any Web browser. This stylesheet provides an easy way of formatting WSDL for display purposes. If you would like to edit WSDL while still avoiding all those XML tags, check out the WSDL Editor in CapeStudio. To learn more about CapeStudio, go to http://www.capeclear.com/products/.

References

WSDL World Wide Web Consortium. Web Services Description Language (WSDL) 1.1
STYLE World Wide Web Consortium. Associating Style Sheets with XML documents
XSLT World Wide Web Consortium. XSL Transformations (XSLT)


Categories: