'NUSoap - calling a method with typed arrays as a parameter

I am using the NuSoap library to call a WCF web service.

I am stuck when calling a particular web method that has a typed array as one of it parameters.

When calling the web method via SOAP UI. I have something like this (and it works)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetBalances>
         <tem:customerIds>
            <arr:guid>228B8C4E-D395-F87D-0000-00000013022F</arr:guid>           
         </tem:customerIds>
         <tem:brandName></tem:brandName>
         <tem:currencyCode>EUR</tem:currencyCode>
      </tem:GetBalances>
   </soapenv:Body>
</soapenv:Envelope>

I am trying to call this same request usign NUSoap like this:

$params = array("customerIds" =>
            array(
                "guid" => '228B8C4E-D395-F87D-0000-00000013022F'
            ),
            "brandName" => "",
            "currencyCode" => "EUR"
        );

$result = $client->call('GetBalances', $params);

But unfortunately I do not get any results.

Any idea how the params array should be structed?

Thanks



Solution 1:[1]

I think this is the best way to do that:

$params = array(
             "guid" => "228B8C4E-D395-F87D-0000-00000013022F",
             "brandName" => "",
             "currencyCode" => "EUR"
);

$result = $client->call('GetBalances', $params);

You need to add so many guid, brandName and currencyCode as you need.

So, you have to create a ComplexType and then a SOAP-Envelope to handle a multiarray.

I hope this helps.

Solution 2:[2]

Just ran into this myself... I found passing an array into a key/value array to work.

$params = array(
    "customerIds" => array("guid" => array("228B8C4E-D395-F87D-0000-00000013022F")),
    "brandName" => "",
    "currencyCode" => "EUR"
);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vic Abreu
Solution 2 Roi