ActionWebService API

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 ? :slight_smile:

TIA,
ngw

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 ? :slight_smile:

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

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

On 7/31/06, Nicholas W. [email protected] wrote:

  :assignment => :string,

  {:subject => :string},

TIA,
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Kent

http://www.datanoise.com

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:inobj2soap’
/opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:127:in _obj2soap' /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:47:inobj2soap’
/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:inobj2soap’
/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:inencode_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:inweb_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:indispatch_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:indispatch_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:inmeasure’
/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:inperform_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:inperform_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:inperform_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:inprocess_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:inprocess’
/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:inhandle_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:inservice’
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /opt/local/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:95:instart’
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:23:instart’
/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:indispatch’
/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:inrequire’
/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:inrequire’
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

On 7/31/06, Nicholas W. [email protected] 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

http://www.datanoise.com

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:incast’
/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:incast_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:inweb_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:ininvoke_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:inmeasure’
/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:ininvoke_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:ininvoke_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:inperform_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:inmeasure’
/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:inperform_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:inprocess_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:indispatch’
/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:inservice’
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:92:instart’
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:82:instart’
/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:inrequire’
/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:inrequire’
/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

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