SOAP查询错误

时间:2016-04-20 14:35:11

标签: php web-services soap xquery

我想使用SOAP和xQuery查询本地存在的数据库上的XML文件,但是我在浏览器中收到以下错误:

功能:

array(10){[0] => string(56)" getResourceResponse getResource(getResource $ parameters)" [1] => string(38)" queryResponse query(query $ parameters)" [2] => string(44)" connectResponse connect(connect $ parameters)" [3] => string(47)" retrieveResponse retrieve(检索$ parameters)" [4] => string(53)" disconnectResponse disconnect(断开$ parameters)" [5] => string(68)" getResourceDataResponse getResourceData(getResourceData $ parameters)" [6] => string(41)" xqueryResponse xquery(xquery $ parameters)" [7] => string(59)" retrieveDataResponse retrieveData(retrieveData $ parameters)" [8] => string(77)" retrieveByDocumentResponse retrieveByDocument(retrieveByDocument $ parameters)" [9] => string(65)" listCollectionResponse listCollection(listCollection $ parameters)" }

SoapFault异常:[soapenv:Server.userException] C:\ xampp \ htdocs \ phexist \ helloclient.php中的java.lang.NullPointerException:8堆栈跟踪:#0 [内部函数]:SoapClient-> __ call(& #39; xquery',数组)#1 C:\ xampp \ htdocs \ phexist \ helloclient.php(8):SoapClient-> xquery(' Ross')#2 {main}

服务器代码:

<?php 
include ('include/eXist.php');
function xquery($firstName) { 
return "Hello ".$firstName; 
//sayhello

 try
{
$db = new eXist();
# Connect
$db->connect() or die ($db->getError());

$query = 'for $line in //Orders/Taxes return $line';

print "<p><b>XQuery:</b></p><pre>$query</pre>";

# XQuery execution
//$db->setDebug(TRUE);
$db->setHighlight(FALSE);
$result = $db->xquery($query) or die ($db->getError());
}



 ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache 
 $server = new SoapServer("http://localhost:8080/exist/services/Query?wsdl"); 
$server->addFunction("xquery"); 
$server->handle(); 
 ?> 

客户代码:

<?php
$client = new SoapClient("http://localhost:8080/exist/services /Query?wsdl");
echo "Functions:<br/><br/>";
echo var_dump($client->__getFunctions());
echo "<br/><br/>";
try
{
$return = $client->xquery("Ross");
echo($return."<br>");
}
catch(SoapFault $soapFault)
{
echo ($soapFault);

}

?> 

1 个答案:

答案 0 :(得分:0)

You're returning the result of 'sayhello' rather than the xquery. Distributed Computing module??