provide data back in XML (non-XHTML) format
Frameworks like Ruby on Rails have built-in functionality for consuming RESTful web services, but expect data to be returned in a more typical XML or JSON payload.
Student Web Service, Person Web Service, and Financial Web Service all have XML,JSON payloads. These are our biggest web services to date and we have more upgrades coming to our smaller web services.
Please see client docs for how to access the new payloads at http://webservices.washington.edu
Armon Dadgar commented
JSON would be preferable. It would be much simpler to parse.
Bradley Bell commented
In the meantime, perhaps the existing output could be tweaked so that it is at least valid xhtml. Running the output through http://validator.w3.org/ shows a lot of errors that could be easy to fix.
We are getting there. Check out a new resource in SWS that has XML and JSON formats.
In addition, FWS and the rest of SWS resources will be available in both formats later this year or beginning of next year.
Dylan W commented
If I had to choose, JSON, since that would make AJAX apps that much easier to use. You can pry XML from my cold dead fingers, but JSON is going to get the data in the hands of more people.
Matt Harris commented
Tony, to answer your question... If you forced me to choose between XML and JSON, I guess I would choose JSON (it's simpler, more lightweight, maps well to existing programming structures, and all the cool kids are doing it). That said, Rails (and probably most other frameworks) will just as easily use either, and if not, it's pretty trivial to convert from JSON to XML and back. I'm sure others are more passionate about JSON being better or XML being better though...
Dylan W commented
JSON is fine too, but either XML or JSON will just deliver the content and allow for far easier parsing than the HTML being used.
I would give all my votes to this if I could. Just talked with Tony C, thanks for the link. ;-)
This request is a must I would say and would love to see this. Shouldn't be too hard to write out json and xml if you are already doing xhtml. Never worked with ruby, all c# and java here so this would be a plus.
Lucian DiPeso commented
I agree. If SWS could provide data back in a variety of formats, e.g., XHTML, XML, JSON, etc., that would be great. We currently use SWS in our PHP web apps, which has parsers for XML and JSON, but at this point I'm having to scrape out the needed data using regex, which is prone to more errors or issues than using prebuilt XML/JSON parsers.
Perhaps SWS could look at the "Accept" request header or the file extension to see how data should be returned.
Matt Harris commented
In regards to the benefits of returning an XML payload:
I can only speak to Rails specifically because that's what I develop in... but I believe it's a similar case for other Rails-type frameworks.
Rails uses a database abstraction class called "ActiveRecord" that makes interacting with the DB insanely simple and saves you from ever having to write a bit of SQL (it automatically maps DB records to Ruby objects). As a companion, Rails also ships with an abstraction class for mapping RESTful resources as models called "ActiveResource." The cool thing about ActiveResource is that you can consume a RESTful resource with literally three lines of code:
class Person < ActiveResource::Base
self.site = "http://api.people.com:3000/"
Of course, for more complex setups, it takes a wee bit more (e.g., specifying certificates for authentication, custom element names, different "primary key", etc.). But then ActiveResource exposes all the CRUD methods just like ActiveRecord... for example `bob = Person.find(1)` will pull Person with ID # 1 from the web service and make all of its attributes accessible on the `bob` object. More about all this is available in the Rails API about ActiveResource (http://apidock.com/rails/ActiveResource/Base).
The BIG GOTCHA with ActiveResource is that it currently can only handle one of two format types: XML and JSON. Theoretically you can also write your own custom format to consume other things, but that doesn't look simple. If I'm going to go to that trouble, I might as well use some of the other tools used for parsing your XHTML directly.
Since you're using Microformats, there are tools out there to parse those outside of the scope of ActiveResource as well. For instance, a ruby gem called mofo exists and looks pretty easy to use but it only supports certain pre-defined microformats (hCard, hCalendar, hReview, hEntry, hResume, XOXO, Geo, Adr, and XFN). But I don't think SWS uses standard Microformats (right?) so, again, it requires manually parsing the data.
From one perspective, I can imagine someone saying "Stop being a lazy Rails programmer and parse the data just like everyone else!" but the whole idea behind Rails is to be lazy when you *can* be lazy... spend less time writing code to parse data and more time working on things that matter to users.
This, in a nutshell, is why I would really love to have the SWS provide an XML payload.
We're looking to be able to consume Web Services from mainframe processes, and the parser that we have available to us allows us to retrieve specific elements from xml strings, whereas with xhtml we have to "get next element" until we have them all, and then process them internally. So it's a lot more coding - and it's very much slower.
Currently, we're not necessarily looking at consuming Student WS data - we're more interested in Financials, but my understanding is that if the AIS folks solve this for one WS system, then it'll be solved for all.