Arrays of objects as parameters to webservices

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?

Joerg D. 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 :slight_smile: 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:indecode_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:intest_profile_companies’

help anybody please? :slight_smile:


Cheers,
Agnieszka

Agnieszka F. wrote:

Joerg D. 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 :slight_smile:

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

Agnieszka F. wrote:

Agnieszka F. 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 F.