views:

22

answers:

1

I developed a web site using rails 2.3.8, and a IM server using openfire(java). I want to share some data between them, or exactly rails as provider, openfire as consumer. A possible way is using web service. But it seems that rails 2.x has deprecated the default SOAP support, I installed the gem activewebservice, but there is lack of documents to show how to using it. I googled an example in IBM's site, but there seems something wrong to follow this guide in rails 2.3.8. Can anyone give me an example? I know there is another way to provide the web service is using rails' default RESTful-type web service, but how to configure the java side to support this?

A: 

Rails has support for RESTful web-services OOTB, so if you have developed your rails application using scaffold generator then your application is already providing a RESTful API. Now as your IM server is the consumer, all you have to do is to make your IM server call the RESTful API provided by the rails application.

Calling RESTful API means sending HTTP (GET/POST/PUT/DELETE) requests to the REST server(Rails App). So all you need to do, is plugin some java code to the openfire server which will send the HTTP requests adhering to the REST conventions and send/receive data in a suitable serialization format(XML/JSON/etc). There is a plugin mechanism in openfire which which probably may help you achieve this.

As far as RESTful calls are concerned, this can be achieved in any of the below methods:

  1. Use a REST Client library provided by JAX-RS implementations like Jersey, Apache wink, etc.
  2. Use any HTTP client library to send/receive HTTP requests/response and a XML/JSON/etc library to serialize/de-serialize the data.
agupta666