# Web Services: Returning multiple values

**URL:** <https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177>\
**Category:** Rails\
**Created:** [November 16, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177 "2006-11-16T15:04:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 16, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177/1 "2006-11-16T15:04:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 16, 2006, 3:58pm UTC](https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177/2 "2006-11-16T15:58:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 16, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177/3 "2006-11-16T16:14:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@dougal](https://www.ruby-forum.com/u/dougal)\
**Post date:** [November 16, 2006, 11:02pm UTC](https://www.ruby-forum.com/t/web-services-returning-multiple-values/76177/4 "2006-11-16T23:02:03Z")

</div>

On 11/16/06, Douglas S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

> **[DATANOISE.COM](https://www.datanoise.com/)**
>
> DATANOISE.COM - Contact us for any business inquiries
