# ActionWebService API

**URL:** <https://www.ruby-forum.com/t/actionwebservice-api/100673>\
**Category:** Rails\
**Created:** [July 31, 2006, 10:55am UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673 "2006-07-31T10:55:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 10:55am UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/1 "2006-07-31T10:55:01Z")

</div>

Hi \*,  
I need to pass a hash to a webservice, so I defined my API with:

api\_method :search,  
:expects =\> [{  
:tags =\> :string,  
:assignment =\> :string,  
:resource =\> :string,  
:lesson\_plan =\> :string,  
:subject =\> :string,  
:all\_types =\> :string  
}], :returns =\> [[Resource]]

when I try to test the webservice with scaffold the signature doesn’t  
seem to be correct:

Resource[] Search(string subject)

What’s happening here ? 🙂

TIA,  
ngw

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 3:16pm UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/2 "2006-07-31T15:16:46Z")

</div>

Il giorno 31/lug/06, alle ore 10:54, Nicholas W. ha scritto:

> ```
> :all_types => :string
> }], :returns => [[Resource]]
> 
> ```
> 
> when I try to test the webservice with scaffold the signature  
> doesn’t seem to be correct:
> 
> Resource[] Search(string subject)
> 
> What’s happening here ? 🙂

class ResourceApi \< ActionWebService::API::Base

api\_method :search,  
:expects =\> [  
{:tags =\> :string},  
{:assignment =\> :string},  
{:resource =\> :string},  
{:lesson\_plan =\> :string},  
{:subject =\> :string},  
{:all\_types =\> :string}], :returns =\> [[Resource]]

end

This one works with xmlrpc, but not with SOAP.  
The error is “cannot map Array to SOAP/OM.”  
Does someone know how to solve ?

TIA,  
ngw

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 4:34pm UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/3 "2006-07-31T16:34:04Z")

</div>

A exception stack trace and a small example would be helpful.

On 7/31/06, Nicholas W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :assignment => :string,
> 
> {:subject => :string},
> 
> ```
> 
> TIA,  
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

## – Kent

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

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 6:30pm UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/4 "2006-07-31T18:30:17Z")

</div>

Il giorno 31/lug/06, alle ore 16:32, Kent S. ha scritto:

> A exception stack trace and a small example would be helpful.

Sure.  
The stack trace:

/opt/local/lib/ruby/1.8/soap/mapping/registry.rb:468:in `_obj2soap' /opt/local/lib/ruby/1.8/soap/mapping/registry.rb:420:in`obj2soap’  
/opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:127:in `_obj2soap' /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:47:in`obj2soap’  
/opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:360:in  
`protect_threadvars' /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:43:in`obj2soap’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/protocol/soap\_protocol/marshaler.rb:35:in  
`ruby_to_soap' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/protocol/soap_protocol.rb:114:in`encode\_response’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/dispatcher/abstract.rb:186:in  
`web_service_create_response' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/dispatcher/abstract.rb:59:in`web\_service\_invoke’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/dispatcher/abstract.rb:22:in  
`invoke_web_service_request' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/dispatcher/action_controller_dispatcher.rb:53:in`dispatch\_web\_service\_request’  
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/dispatcher/action_controller_dispatcher.rb:51:in`dispatch\_web\_service\_request’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/scaffolding.rb:83:in `invoke_submit' /opt/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/scaffolding.rb:67:in `invoke_submit' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/base.rb:910:in`perform\_action\_without\_filters’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/filters.rb:368:in `perform_action_without_benchmark' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/benchmarking.rb:69:in`perform\_action\_without\_rescue’  
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/benchmarking.rb:69:in`perform\_action\_without\_rescue’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/rescue.rb:82:in `perform_action' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/base.rb:381:in`process\_without\_filters’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/filters.rb:377:in  
`process_without_session_management_support' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/session_management.rb:117:in`process’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in  
`dispatch' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb: 115:in`handle\_dispatch’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick\_server.rb:  
81:in `service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in`service’  
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /opt/local/lib/ruby/1.8/webrick/server.rb:173:in`start\_thread’  
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:95:in`start’  
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `start' /opt/local/lib/ruby/1.8/webrick/server.rb:23:in`start’  
/opt/local/lib/ruby/1.8/webrick/server.rb:82:in `start' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb: 67:in`dispatch’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/  
webrick.rb:59  
/opt/local/lib/ruby/vendor\_ruby/1.8/rubygems/custom\_require.rb:21:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/ active_support/dependencies.rb:147:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30  
/opt/local/lib/ruby/vendor\_ruby/1.8/rubygems/custom\_require.rb:21:in  
`require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/ active_support/dependencies.rb:147:in`require’  
script/server:3  
-e:4

The search function needs a set of flags and a keyword (tags), it  
should search inside the db for matching records (Resource models)  
and return an array of Resource objects.  
I think the problem is the return value, but I don’t know how to fix  
that. I searched the documentation and I think it’s correct to use  
something like :returns =\> [[Resource]] for an array of Resource  
objects, and in fact it works like a charm with XML-RPC. The problem  
is soap …  
Is this a rails bug ?

ngw

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/5 "2006-07-31T19:05:16Z")

</div>

On 7/31/06, Nicholas W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The search function needs a set of flags and a keyword (tags), it should  
> search inside the db for matching records (Resource models) and return an  
> array of Resource objects.  
> I think the problem is the return value, but I don’t know how to fix that. I  
> searched the documentation and I think it’s correct to use something like  
> :returns =\> [[Resource]] for an array of Resource objects, and in fact it  
> works like a charm with XML-RPC. The problem is soap …  
> Is this a rails bug ?

No. For an array of Resource objects you must specify

:returns =\> [Resource]

as a result signature.

## – Kent

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

---

<div class="post-metadata">

**Author:** ![Nicholas\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nicholas\_W](https://www.ruby-forum.com/u/Nicholas_W)\
**Post date:** [July 31, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/actionwebservice-api/100673/6 "2006-07-31T19:33:39Z")

</div>

Il giorno 31/lug/06, alle ore 19:02, Kent S. ha scritto:

> > :returns =\> [[Resource]] for an array of Resource objects, and in  
> > fact it  
> > works like a charm with XML-RPC. The problem is soap …  
> > Is this a rails bug ?
> 
> No. For an array of Resource objects you must specify
> 
> :returns =\> [Resource]
> 
> as a result signature.

Thanks a lot for your help, but it doesn’t work …  
The error is “Don’t know how to cast Array to Resource”.

/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/casting.rb:129:in `cast_to_structured_type' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/casting.rb:60:in`cast’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/casting.rb:38:in `cast_returns' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/casting.rb:25:in`cast\_returns’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/api.rb:193:in `cast_returns' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/dispatcher/abstract.rb:182:in`web\_service\_create\_response’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/dispatcher/abstract.rb:59:in `web_service_invoke' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/dispatcher/abstract.rb:22:in`invoke\_web\_service\_request’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/dispatcher/action\_controller\_dispatcher.rb:53:in  
`dispatch_web_service_request' /opt/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/  
action\_web\_service/dispatcher/action\_controller\_dispatcher.rb:51:in  
`dispatch_web_service_request' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/scaffolding.rb:83:in`invoke\_submit’  
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /opt/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/ action_web_service/scaffolding.rb:67:in`invoke\_submit’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/base.rb:910:in `perform_action_without_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/filters.rb:368:in`perform\_action\_without\_benchmark’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/benchmarking.rb:69:in `perform_action_without_rescue' /opt/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/benchmarking.rb:69:in `perform_action_without_rescue' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/rescue.rb:82:in`perform\_action’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/base.rb:381:in `process_without_filters' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/ action_controller/filters.rb:377:in`process\_without\_session\_management\_support’  
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/  
action\_controller/session\_management.rb:117:in `process' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in`dispatch’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick\_server.rb:  
115:in `handle_dispatch' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick_server.rb: 81:in`service’  
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:162:in`start\_thread’  
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in `start' /opt/local/lib/ruby/1.8/webrick/server.rb:92:in`start’  
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in `start' /opt/local/lib/ruby/1.8/webrick/server.rb:82:in`start’  
/opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/webrick\_server.rb:  
67:in `dispatch' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/servers/ webrick.rb:59 /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/  
active\_support/dependencies.rb:147:in `require' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/commands/server.rb:30 /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/  
active\_support/dependencies.rb:147:in `require’  
script/server:3  
-e:4

TIA,  
ngw
