I used the SoapClient Library to get data from TecDoc webservices. All of the ws functions work except this special function whose parameter contains an array in an array.
Here is my code:
$client = new SoapClient("http://webservice-cs.tecdoc.net/pegasus-2-0/wsdl", array("trace" => true));
//array of product ids
$data = array(
'empty' => false,
'array' => array(361024, 365118),
);
$params = array(
'provider' => 23014,
'lang' => 'es',
'country' => 'es',
'articleId' => $data,
'attributs' => true,
'documents' => true,
'documentsData' => false,
'eanNumbers' => false,
'immediateAttributs' => true,
'immediateInfo' => false,
'info' => true,
'prices' => false,
'priceDate' => null,
'normalAustauschPrice' => false,
'mainArticles' => false,
'oeNumbers' => true,
'replacedNumbers' => false,
'replacedByNumbers' => false,
'usageNumbers' => false,
'normalAustauschPrice' => false,
);
$test = $client->__soapCall('getDirectArticlesByIds2', array('in0' => $params));
var_dump($test);
The goal of the above function is to get all product's information from their id (array of ids).
SoapClient shows the following error:
[soapenv:Server.userException] org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. in C:\xampp 1.8.1\htdocs\www\test.php:59 Stack trace: #0 C:\xampp 1.8.1\htdocs\www\test.php(59): SoapClient->__soapCall('getDirectArticl...', Array)
The other functions that I don't have to pass an array parameter to a property work perfectly.
I found out that 'array' => array(361024, 365118) causes the error. If I let the array be NULL, the above code works, just returns empty result (because no product ids are passed).
$data = array(
'empty' => false,
'array' => null,
);
An example of functions that works well:
static public function addDynamicIp($hour)
{
$client = new SoapClient("http://webservice-cs.tecdoc.net/pegasus-2-0/wsdl");
$params = array(
'provider' => 23014,
'address' => $_SERVER['REMOTE_ADDR'],
'validityHours' => $hour,
);
$client->__soapCall('addDynamicAddress', array('in0' => $params));
}
With the same parameters (contains an array in an array), NuSOAP can execute the first codes successfully, return right result. But NuSOAP causes too many troubles especially slow speed. We are forced to use SoapClient.
So I guess that NuSOAP library has somewhere convert all child array to suitable format but SoapClient doesn't. Tried some solutions but no luck. Please help me to solve this.