XML can so easily be abused…

I am getting really tired of seeing web services (or RSS feeds, or .NET methods, or anything else) with large blocks of complex, structured data that is exposed as “String”.

You call the web service, you get back this big string, which you then load into an XMLDocument and off you go (or XPath Navigator, etc…) … but if they had just defined the real structure in the first place, I wouldn’t have to do anything… I’d have a nice “weather” structure or “employee” object inside an “employees” collection… now, I can certainly massage/convert/deserialize their XML (well, I know it is XML, their wsdl says “String”) into a nice object collection, but why should I have to!?! They went to all of the work to produce formatted, structured XML output, why type it is as String?

Ach, maybe I’m missing something here, but I’m starting to get grumpy. I remember trying to show off an easy web service connection when I was at a booth at a convention so I randomly picked a web service listed on xmethods.com, and I picked the wrong one… now, don’t get me wrong… it worked fine, but I had to parse XML to get the temperature which made my simple demo a little more complicated than I wanted!

What I wanted was;

Dim myTemp as GlobalWeather.TemperatureResponse = GlobalWeather.GetTemperature(“Redmond”,”United States”)


(note, don’t try that, it won’t work… I’m just dreaming…)

There are plenty of web services (on xmethods and elsewhere) that work the right way (in my mind at least), but I keep running into ones that don’t…. or .NET assemblies that accept a String as a parameter, that is actually a String containing an XML document… instead of a properly defined structure… even though the XML you pass in has to conform to a very exact specification… why would anyone do that? Well some people tell me it is for flexibility, but I doubt it often works out for them.

Tonight I started thinking of adding weather information to my music system (hey, it might seem odd, but it is up on the TV screen… might as well show some useful info) but I didn’t want to scrape some web site, possibly breaking their terms of use and/or annoying them, so I went looking for a weather site that offered a feed or a web service and I found www.rssweather.com. Wow, that should just rock, right? Bugger. The weather info is dumped in as a HTML block in the body of each feed item… which probably works great in SharpReader, but why oh why couldn’t they have included it in both a HTML format and as structured XML? RSS is extensible, they could have added their own namespace … bah. Guess I’ll keep looking.

Note that some web services should be string in, string out… like this cool looking RTF To HTML service I saw on xmethods…

[Listening to: Clint Eastwood – Gorillaz – Big Shiny Tunes 6 (03:45)]
Comments (5)

  1. Colt says:

    Thanks for sharing Duncan!

    I just consume the RSS from RssWeather into my local blogging site and it rocks!

  2. Anonymous Coward says:

    You’re coming at things from a .NET angle and forgetting that web services do not begin and end there. Microsofts own COM based SOAP toolkit 2 supports the XSD types like string but you certainly need to do a lot of heavy lifting to comsume complex types in pre-.NET world. I’m not 100% sure but it seems plausible that other platforms suffer the same deficiencies.

  3. John Cavnar-Johnson says:

    Gee… maybe because String is the only responsible way to transport an XML Document across a network?

    Haven’t you guys learned anything about versioning, cross-platform compatibility, and resilience in distributed computing?

  4. a reply says:

    You are missing part of the picture here. If you have a web service that takes 50 or more parameters (we have one that can take over 200), with complex business logic, AND new, non required elements will be added, XML is much more flexible than actually putting all that into the SOAP call structure.

    Simple and static things: do structures, params, etc.

    Complex and fluid things: XML is much easier to live with…

  5. Kent Sharkey says:

    Some of you seem to be missing D’s point. He’s not saying, "Don’t pass XML as data", he’s saying, "Don’t pass it as ‘string’ — pass it as what it is".

    Both Axis and .NET (and possibly other toolkits, but those are the ones I’m familiar with) will allow you to serialize your big-honkin’-data-structure as XML. So, why not pass it as the XSD defined type? If your client is .NET, they can serialize it to the appropriate .NET type. Ditto for Axis (just to a Java type). Best of all possible worlds, and you’re not staring at a WSDL file that says "Send me a string. Guess what it should look like."

    TTFN – Kent