A WSDL formatter for reading SOAP contracts
WSDL (Web Services Description Language) files describe what a SOAP service offers, and they are usually generated by frameworks such as JAX-WS, WCF or Apache CXF. The output is often one enormous line, which makes it hard to answer simple questions like "what does this operation return?". This WSDL formatter re-indents the document so each section and operation is visible, and it checks the XML is well-formed on the way.
Example
<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/"><message name="GetPriceInput"><part name="ticker" type="xsd:string"/></message><portType name="StockQuotePortType"><operation name="GetPrice"><input message="tns:GetPriceInput"/></operation></portType></definitions>
becomes:
<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="GetPriceInput">
<part name="ticker" type="xsd:string"/>
</message>
<portType name="StockQuotePortType">
<operation name="GetPrice">
<input message="tns:GetPriceInput"/>
</operation>
</portType>
</definitions>
Reading a WSDL 1.1 file, top to bottom
| Section | What it defines |
|---|---|
<types> | The data types used in messages, normally as an embedded XML Schema. |
<message> | The input and output payloads, each made of named <part> elements. |
<portType> | The abstract interface: operations and which messages they take and return. |
<binding> | How a port type maps onto a protocol, such as SOAP style (rpc or document) and soapAction values. |
<service> | Concrete endpoints: each <port> points to a binding and has an address. |
To trace an operation, start at the <soap:address location> in the service, follow the port's binding attribute, then the binding's type to the port type, and from the operation to its messages. The tns: prefix in these references points to the WSDL's own target namespace. WSDL 2.0 uses different names (description, interface, endpoint), but it is formatted the same way.
Tips for real-world WSDL files
- Imported schemas. Many WSDLs reference external XSD files with
xsd:importorwsdl:import. The formatter works on the file you paste; load each imported XSD separately to read it. - Validate means well-formed. The Validate button reports
Valid WSDL ✓with the root element and element count. It does not check that everytns:reference points to an existing message or binding. - Documentation blocks.
<documentation>elements are content, not comments, so they are kept even with Remove comments on.
Once you know the operation, format the request and response envelopes with the SOAP formatter. To list every operation name quickly, run //*[local-name()='operation']/@name in the XPath tester. The general XML formatter has the same options for any other XML.