Multiple return values in action web service

Hi all,

Does anyone have any advice about returning multiple values from an
ActionWebService? That is, I’d like to implement something like the

api_method :do_something,
:expects => [{:id => :string}],
:returns => [{:return_code => :int},
{:return_text => :string}]

The easy way to do it would be to wrap everything in a struct:

class ReturnStatus < ActionWebService::Struct
member :return_code, :int
member :return_text, :string

api_method :do_something,
:expects => [{:id => :string}],
:returns => [ReturnStatus]

Then I could implement do_something as follows:

def do_something => 0,
:return_text => “Success”)

But, unfortunately, I’m trying to re-create an existing web service and
don’t have this option. The problem with a struct is that it translates
into another layer in the XML, and the existing clients won’t know how
parse it. Here’s an example of the return code (minus namespaces) if I
a struct.

<?xml version="1.0" encoding="UTF-8" ?> Success 0

But that object is getting in the way. What I’d like is:

<?xml version="1.0" encoding="UTF-8" ?> Success 0

I’ve looked a bit at the soap4r files, because if ActionWebService
work, I may have to switch to using that. But even there, I’m having
trouble understanding if I’ll be able to define a mapping that will keep
this extra layer from being created.

Thanks in advance for your input.

Jacob Maine

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs