Web Services: Returning multiple values

Ok, so I have an API definition as so…

api_method :frame_out,
:returns => [:boolean,:int,:int,:string,:string]

and a controller method as follows…

def frame_out
return [false, 0, 0, ‘’,’’]
end

When I run this using the test scaffolding I get a “Don’t know how to
cast Array into Boolean” Error.

What am I doing wrong?

Cheers.

Dougal.

On Nov 16, 2006, at 8:04 AM, Douglas S. wrote:

end

When I run this using the test scaffolding I get a “Don’t know how to
cast Array into Boolean” Error.

What am I doing wrong?

I think you need to try an additional level of indirection on your
return value:

:returns => [[:boolean, :int, :int, :string, :string]]

This will return an array containing a boolean, two ints and two
strings. Your prior definition didn’t do that. I think this is due to
the peculiarity of how the syntax looks for the api definition. The
first pair of brackets don’t actually define an array from the API
standpoint.

I’m not explaining this well… sorry. Just try the above and see if
it fixes your problem.

cr

Chuck R. wrote:

:returns => [[:boolean, :int, :int, :string, :string]]

Oops, I wrote my code wrong, the controller method should in fact
return a boolean, two ints and two strings…

return true, 0, 0, ‘’, ‘’

This is how I would usually return multiple values to a method call.
Unfortunately, I now get a “Don’t know how to cast String into Boolean”
error. :o(

Help is, and will be, appreciated.

Ta.

On 11/16/06, Douglas S. [email protected] wrote:

This is how I would usually return multiple values to a method call.
Unfortunately, I now get a “Don’t know how to cast String into Boolean”
error. :o(

Help is, and will be, appreciated.

AFAIK, SOAP doesn’t allow arrays of different types. You can introduce
AWS::Struct class and use it as a returning value.


Kent