SOAP Cheat Sheet

By Lars Magne Ingebrigtsen

SOAP and WSDL are going the way of the dodo, fortunately. The enterprisey world is buzzing with REST, where you, like, just use an URL to do some RPC. Whodathunk! URLs! Whatever will the come up with next?

For the unfortunate ones among you who still have to deal with SOAP crap, and don't want to install a gazillion SOAP libraries, here's a minimal primer.

  1. Find the WSDL you've been requested to follow.
  2. In there, you'll find the call you want to make. It'll be in the operation tags. For instance:
    <operation name='fetchNews'>
  3. The call will probably take a parameter. It'll look like this:
       <complexType name='FetchNews'>
        <sequence>
         <element name='lastPublicationId' type='long'/>
        </sequence>
       </complexType>
    
    ...
    
     <message name='DisclosureNewsService_fetchNews'>
      <part element='tns:fetchNews' name='parameters'/>
     </message>
    
That's it! You need to know no more.

Create a text file like the one below (which is 92% boilerplate), and POST it to the service, and you'll get some god-awful XML back that you can parse.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:xsd="http://www.w3.org/1999/XMLSchema" 
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<fetchNews xmlns="">
<parameters>9</parameters>
</fetchNews>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And continue living happily, hoping you'll never actually have to learn what SOAP is really about.


2007-11-20 03:23:34