XiMpLode

It has been said before, but it deserves repeating: XML is overused. And often, made unnecessarily over-complicated for the task. Take for instance the example “A Simple Soap Client“.

Here is the request:

<?xml version="1.0"?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <SOAP-ENV:Body>
    <calculateFibonacci
      xmlns="http://namespaces.cafeconleche.org/xmljava/ch3/"
      type="xsi:positiveInteger">10</calculateFibonacci>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is the response:

<?xml version="1.0"?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" />
  <SOAP-ENV:Body>
    <Fibonacci_Numbers
      xmlns="http://namespaces.cafeconleche.org/xmljava/ch3/">
      <fibonacci index="1">1</fibonacci>
      <fibonacci index="2">1</fibonacci>
      <fibonacci index="3">2</fibonacci>
      <fibonacci index="4">3</fibonacci>
      <fibonacci index="5">5</fibonacci>
      <fibonacci index="6">8</fibonacci>
      <fibonacci index="7">13</fibonacci>
      <fibonacci index="8">21</fibonacci>
      <fibonacci index="9">34</fibonacci>
      <fibonacci index="10">55</fibonacci>
    </Fibonacci_Numbers>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Dear $DEITY, why do we need to define a new data type to hold a list of integers? And what in the world is that “index” attribute doing there? IT’S A FUCKING LIST. This is like a real-life example of the old XML binary encoding joke:

<data>
  <binary>
    <bit index="0">0</bit>
    <bit index="1">0</bit>
    <bit index="2">1</bit>
    ...
    <bit index="n">1</bit>
  </binary>
</data>

It’s just sad…

For the sake of it, let’s compare to a JSON-RPC version: (not the epitome of efficiency mind you, but an order of magnitude better)

--> { "method": "calculateFibonacci", "params": [10,], "id": 1}
<-- { "result": [1,1,2,3,5,8,13,21,34,55], "error": null, "id": 1}

Which would you rather use? :)

One Response to “XiMpLode”

  1. TK Says:

    I’ve taken the policy of only ever using SOAP for big corporate 3rd party integrations. (Because a JSON schema just isn’t as maintainable apparently…)

Leave a Reply


<Kered.org>   © Copyright 2000-2005 by Derek Anderson
Get Firefox