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.
- The AjxSoapDoc._SOAP_URI must be set to http://schemas.xmlsoap.org/soap/envelope/.
- 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 / .
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.