0

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

Vitek Karas MSFT
  • 12,770
  • 1
  • 31
  • 29
Gabriel Spiteri
  • 4,596
  • 10
  • 39
  • 57
  • i think, the prefix is making the problem., try changing 'arr' to 'tem' – Kris May 14 '12 at 10:09
  • Try the same input structure using the PHP native `SoapClient`. What exactly is in `$result`? Use `print_r($result);` If you can, post the WSDL. – MrCode May 30 '12 at 11:52

2 Answers2

0

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.

Vic Abreu
  • 493
  • 4
  • 12
0

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"
);
Roi
  • 1,367
  • 14
  • 17