views:

67

answers:

1

I am working with a large website written in Ruby on Rails. Thanks to the support for REST in Rails 2, the site's business logic is all accessible via a consistent XML API. Now I want to be able to easily write one or more JavaScript frontends to the site that interact with the generated Rails XML API.

Ideally, an automated wrapper for the API could be created in JavaScript, since this would minimize the effort required in writing XML processing code for the more than 500 API functions. How, then, can I automatically generate a wrapper around a given XML API in JavaScript so that it's more pleasant to work with? I've worked with solutions of this nature for Java that generate classes and methods to wrap an API, so my current thinking is that I want something of that nature for JavaScript. I'd be open to an alternative take on the problem, though.

+1  A: 

There's a great tool by thoughtbot guys called jester: a JavaScript implementation of REST, with syntax modeled after ActiveResource. You can use it to write code to read, create, and update the data on your server.

You can find several examples on the usage page.

Anton Mironov