Forum: Ruby on Rails Arrays of objects as parameters to webservices

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2006-01-30 11:29
I think I am missing something terribly obvious. Is it possible to have
an :expects parameter for a webservice that is an array of objects? I
want to have a single webservice that expects all my line items (for an
order). Is this something that is possible?
5b132632f47e8c7e2a83157cef4649c8?d=identicon&s=25 Agnieszka Figiel (agnessa)
on 2006-12-19 09:04
Joerg Diekmann wrote:
> I think I am missing something terribly obvious. Is it possible to have
> an :expects parameter for a webservice that is an array of objects? I
> want to have a single webservice that expects all my line items (for an
> order). Is this something that is possible?

Hello,

almost a year later I'm having the same problem :) I need to pass
several parameters to a webservice, one of which is an array of structs.
I tried to define it like this:

api_method :profile_companies,
             :expects => [{:province => :string},{:area =>
:string},{:city => :string},{:postal_code =>
:string},[ProfileConditionStruct]],
             :returns => [[CompanyStruct]]

where ProfileConditionStruct and CompanyStruct are simple structs, no
complex types involved inside of them. the method is defined in the
controller, then I call the service from a test:

invoke :profile_companies, 'yada', 'yada', 'yada', 'yada', [c1, c2]

where c1 and c2 are of type ProfileConditionStruct. What I get is:

test_profile_companies(ExternalControllerApiTest):
ActionWebService::Protocol::ProtocolError: Failed to parse SOAP request
message
    /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.6/lib/action_web_service/protocol/soap_protocol.rb:86:in
`decode_response'
    /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.6/lib/action_web_service/test_invoke.rb:60:in
`decode_rpc_response'
    /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.6/lib/action_web_service/test_invoke.rb:11:in
`invoke'
    ./test/functional/external_api_test.rb:21:in
`test_profile_companies'

help anybody please? :)

--
Cheers,
Agnieszka
5b132632f47e8c7e2a83157cef4649c8?d=identicon&s=25 Agnieszka Figiel (agnessa)
on 2006-12-19 10:21
Agnieszka Figiel wrote:
> Joerg Diekmann wrote:
>> I think I am missing something terribly obvious. Is it possible to have
>> an :expects parameter for a webservice that is an array of objects? I
>> want to have a single webservice that expects all my line items (for an
>> order). Is this something that is possible?
>
> Hello,
>
> almost a year later I'm having the same problem :)

Hello again, it seems my problem is connected with something different
and not array parameters. I'll report back when I figure that one out
and get it working so that others have better chances of finding a
useful example.

--
Agnieszka
5b132632f47e8c7e2a83157cef4649c8?d=identicon&s=25 Agnieszka Figiel (agnessa)
on 2006-12-21 11:42
Agnieszka Figiel wrote:
> Agnieszka Figiel wrote:
> Hello again, it seems my problem is connected with something different
> and not array parameters. I'll report back when I figure that one out
> and get it working so that others have better chances of finding a
> useful example.
>

just for the record, the code above was ok, the problem was caused by
http authentication in the webservices controller. I still don't know
how to fix this otherwise than to turn authentication off to see the
tests pass:), I'm referencing the problem in a separate post.

--
Agnieszka Figiel
This topic is locked and can not be replied to.