Search code examples
soapgroovygroovyws

How to send an array of a complex object with GroovyWS


I'm about to call a webservice created in C#, that takes a parameter

KmlSystemVariable[] sysVariables

How can I pass a parameter like that using GroovyWS? It doesn't need to have any values, could be an empty array. Looks like the full class name is Consorte.Pulse.Data.KmlSystemVariable

I enabled logging as described in GroovyWS and complex requests to get the namespace for KmlSystemVariable, and it looks like I can create a KmlSystemVariable with:

proxy.create("org.datacontract.schemas._2004._07.consorte_pulse.KmlSystemVariable")

But how do I create an array of KmlSystemVariable?


Solution

  • It should be enough to just wrap your proxied objects into a Groovy list and use it as the parameter. GroovyWS will do the transformation from List to SOAP array for you behind the scenes.

    Example:

    def ksv1 = proxy.create("org.datacontract.schemas._2004._07.consorte_pulse.KmlSystemVariable")
    def ksv2 = ...
    def ksv3 = ...
    def list = [ksv1, ksv2, ksv3]
    proxy.<some ws method>(list)