# Variable number of parameters on SOAP call?

**URL:** <https://www.ruby-forum.com/t/variable-number-of-parameters-on-soap-call/161906>\
**Category:** Ruby\
**Created:** [March 3, 2009, 6:28pm UTC](https://www.ruby-forum.com/t/variable-number-of-parameters-on-soap-call/161906 "2009-03-03T18:28:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 3, 2009, 6:28pm UTC](https://www.ruby-forum.com/t/variable-number-of-parameters-on-soap-call/161906/1 "2009-03-03T18:28:03Z")

</div>

Is there a way to specify a variable number of parameters on a SOAP  
call?  
Example: Ruby client that is trying to call a Perl SOAP server:

dvr = SOAP::RPC::Driver.new(“[http://samplehost.com:1234](http://samplehost.com:1234)”, “urn:Test”)  
dvr.add\_method(‘vartest’,‘user’,‘passwd’,‘opts’)

‘opts’ can be a variable number of options, so its expecting one or  
more options to show up. If I pass it something like:

tt = [“test1”,“test2”,“test3”]  
dvr.vartest(“user”,“pass”,tt)

the perl SOAP client gets a one element array of an array…not just a  
single array. IE\> p[0][0] =\> “test1”, p[0][1] =\> “test2” p[0][2] =\>  
“test3” …what its expecting is p[0] =\> “test1”, p[1] =\> “test2”, p[2]  
=\> “test3”. This works fine from my perl SOAP client.

Is there a standard way to set up a SOAP function to accept a variable  
number of parameters?? I can’t find anything about it.  
Thanks all:)

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 3, 2009, 6:45pm UTC](https://www.ruby-forum.com/t/variable-number-of-parameters-on-soap-call/161906/2 "2009-03-03T18:45:41Z")

</div>

On 03.03.2009 18:26, John A. wrote:

> tt = [“test1”,“test2”,“test3”]  
> dvr.vartest(“user”,“pass”,tt)
> 
> the perl SOAP client gets a one element array of an array…not just a  
> single array. IE\> p[0][0] =\> “test1”, p[0][1] =\> “test2” p[0][2] =\>  
> “test3” …what its expecting is p[0] =\> “test1”, p[1] =\> “test2”, p[2]  
> =\> “test3”. This works fine from my perl SOAP client.
> 
> Is there a standard way to set up a SOAP function to accept a variable  
> number of parameters?? I can’t find anything about it.  
> Thanks all:)

Did you try the splat operator?

dvr.vartest(“user”, “pass”, \*tt)  
^

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 3, 2009, 6:53pm UTC](https://www.ruby-forum.com/t/variable-number-of-parameters-on-soap-call/161906/3 "2009-03-03T18:53:37Z")

</div>

Robert K. wrote:

> Did you try the splat operator?
> 
> dvr.vartest(“user”, “pass”, \*tt)  
> ^

That just gets me a ‘wrong number of arguments (6 for 3)’ error.  
Thank you for responding 🙂
