Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-06-2005, 04:17 PM
Senior Member
 
Posts: 51
Default Ruby On Rails JSON webservice plugin

I created a plugin for Ruby On Rails so that the activeWebservice can send back a JSON respond instead of a SOAP respond. It chooses the way it responds (JSON or SOAP) to look at a HTTP header (SOAPReturnFormat). If the header is not present, has the value SOAP or has an incorrect value then a SOAP respond is given. If it has the value JSON then a JSON respond will be given.

I rather used the header of the xml envelope but till now it is not clear to me how I can read from it. I must probably decode the soap respond again because the normal behavour of the activeWebservice discards the header. For now I am happy that I succeeded with the HTTP header.

The plugin is far from stable (it hasn't been tested a lot, so bugs are expected) and I question if I build the plugin the correct way. But what the hell, it works.

For everybody who wants to give Ruby On Rails together with ZimbraTK a try, you can download the plugin at http://www.smies.com/projects/ror_pl...ervice_0.1.zip .

You must know that Zimbra uses SOAP1.2 and Ruby on Rails SOAP1.1. This is not a big problem but you must be aware of two things in your ZimbraTK.
  1. The AjxSoapDoc._SOAP_URI must be set to http://schemas.xmlsoap.org/soap/envelope/.
  2. You must send the HTTP header SOAPAction with your request.
    This header contains the path to the soap service( without the domain and the protocol) and the name of the action, seperated with a / .
    Example:
    service = http://localhost:3000/backend/api
    action = FindProductById
    SOAPAction = /backend/api/FindProductById

I will probably create a small package for ZimbraTK in the future that can switch between SOAP 1.1 and SOAP 1.2. When it is done I will share the code.
Reply With Quote
  #2 (permalink)  
Old 11-07-2005, 12:34 PM
Senior Member
 
Posts: 51
Default Update

I made a small update to the plugin. You can download the new version from:
http://www.smies.com/projects/ror_pl...vice_0.1.1.zip

CHANGELOG:

VERSION 0.1.1
-------------------------------------
* The Code property of the Fault object in the return now contains the classname of the thrown exception

Last edited by smies : 11-07-2005 at 01:18 PM.
Reply With Quote
  #3 (permalink)  
Old 12-22-2005, 03:02 PM
Senior Member
 
Posts: 51
Default

I released a new version (0.1.3) of my json_webservice for Ruby on Rails.

Changes:
- When a Time class is encounterd it will be converted to a string with the international date time format: %Y/%m/%d %H:%M:%S.
It is only a minor bugfix but is also only a small plugin.

You can download the plugin here.

Enjoy..
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0