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.
The "Known Compatibility Problems" section of the "TecDoc WebService Interface description" document at page 5 states:
PHP does not implement different integer data types. Depending on the operating system an integer contains 32 or 64 bit. Therefore an automatic implicit mapping from int (32 bit) to long (64 bit) is done on discrete parameters which take a 64 bit value. However, this does not work with arrays, so there functions having arrays of strings containing the numeric values have to be used.
So, as far as I can understand, it seems that with PHP you should use getDirectArticlesByIds2StringList
instead of getDirectArticlesByIds2
.