|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-07 16:20 UTC] jiro at email dot it
Description:
------------
I'm using PHP 5.0.2 with SOAP extension.
I need to call a function with a array as input, and it doesn't serialize -.-
Reproduce code:
---------------
$namespaces=array("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs", "http://www.w3.org/2000/01/rdf-schema#","ns1", "http://purl.org/dc/elements/1.0/", "ns2", "http://purl.org/dc/terms/");
$soap_client=new SoapClient(HOST_XIWA. 'QueryService?wsdl');
$response=$soap_client->queryCollection(XINDICE_COL, $queryst, true, $namespaces);
Expected result:
----------------
$response is the result of the query. It goes with NUSOAP^^
Actual result:
--------------
Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException: No deserializer defined for array type {http://www.w3.org/2001/XMLSchema}string in D:\Tesi2004\tbl\search.php:115 Stack trace: #0 D:\Tesi2004\tbl\search.php(115): SoapClient->queryCollection('queryCollection', Array) #1 D:\Tesi2004\tbl\search.php(97): stampa_commenti('tbl_comment', '/rdf:RDF/rdf:De...', false, Array) #2 D:\Tesi2004\tbl\search.php(256): stampa_un_libro('D:\Tesi2004\tbl\search.php on line 115
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 16:00:01 2025 UTC |
The error occurs on server side. Seems server cannot decode the soap request. To understand (and fix) the problem I need to know the expected soap request and the actual one. You can use the following script to catch SOAP request with ext/soap. <?php $queryst="/rdf:RDF/rdf:Description[ns1:subject='$cat']" ; $namespaces=array("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs", "http://www.w3.org/2000/01/rdf-schema#", "ns1", "http://purl.org/dc/elements/1.0/", "ns2", "http://purl.org/dc/terms/"); $soap_client=new SoapClient('http://jiroland.dyndns.org/QueryService.wsdl', array('trace'=>1, 'exceptions'=>0)); $response=$soap_client->queryCollection('tbl', $queryst, true,$namespaces); echo $soap_client->__getLastRequest()."\n"; echo $soap_client->__getLastResponse()."\n"; var_dump($response); ?>This might be the extra feedback you're looking for. I ran across these symptoms when working with the Google Search SOAP API. Basically, in WSDL Mode, the Soap Client needs the parameters to the operations passed to it as individual functions. Passing an array of parameters causes a SoapFault Exception. Naturally, in Non-WSDL mode, an array of parameters works just fine. In other words, in WSDL Mode, this works: $results = $client->doGoogleSearch('[Google Key]', 'Cornbread', 0, 10, true, '', false, 'english', 'utf-8', 'utf-8'); While this one causes the SOAP Exception: $params = array('key' => '[Google Key]', 'q' => 'Cornbread', 'start' => 0, ...) $result = $clientWSDL->doGoogleSearch($params); Here is the script in its entirety: <?php //BEGIN PARAMS ARRAY $params = array('key' => '[A Google Key]', 'q' => 'Cornbread', 'start' => 0, 'maxResults' => 10, 'filter' => true, 'restrict' => 'countryUS', 'safeSearch' => false, 'lr' => 'english', 'ie' => 'utf-8', 'oe' => 'utf-8'); //END PARAMS ARRAY //BEGIN NONWSDL MODE $clientNonWSDL = new SoapClient(null, array('location' => "http://api.google.com/search/beta2", 'uri' => "urn:GoogleSearch" ) ); //WITH PARAMS AS ARRAY $resultNonWSDL = $clientNonWSDL->__soapCall('doGoogleSearch', $params); echo "<h1>NonWSDL Client Request With Array:</h1>"; echo "<h4>REQUEST:\n" . $clientNonWSDL->__getLastRequest() . "</h4>"; var_dump($resultNonWSDL); //END NONWSDL MODE //BEGIN WSDL MODE $clientWSDL = new SoapClient('http://api.google.com/GoogleSearch.wsdl', array('trace' => true)); //WITH PARAMS AS INDIVIDUAL ITEMS $resultWSDLNonArray = $clientWSDL->doGoogleSearch('[A Google Key]', 'Cornbread', 0, 10, true, '', false, 'english', 'utf-8', 'utf-8'); echo "<h1>WSDL Client Request With String:</h1>"; echo "<h4>REQUEST:\n" . $clientWSDL->__getLastRequest() . "</h4>"; var_dump($resultWSDLNonArray); //WITH PARAMS AS ARRAY $resultWSDLArray = $clientWSDL->doGoogleSearch($params); echo "<h1>WSDL Client Request With Array:</h1>"; echo "<h4>REQUEST:\n" . $clientWSDL->__getLastRequest() . "</h4>"; var_dump($resultWSDLArray); //END WSDL MODE ?>