SOAP,在对象中使用函数


SOAP, functions with in an object

我正在通过soap公开对象的函数,但它给了我错误

服务器

$soap_wrapper = new my_geo_soap_wrapper();
$soap_wrapper->set_geo_app($my_geo);
$server = new SoapServer(null, array('uri' => "urn://localhost/firstmobile"));
$server->setObject($soap_wrapper);
$server->handle();

客户端

$client = new SoapClient(null, array(
    'location' => "http://127.0.0.1/firstmobile/simple_server.php",
    'uri'      => "http://127.0.0.1/firstmobile/"
    ));
$result = $client->__soapCall("geolocate",array($lat,$lng));
print $result;

错误

致命错误:未捕获的SoapFault异常:[SOAP-ENV:Server]调用中的非对象上的成员函数geolocate()/home/imran/projects/firstmobile/simple_client.php:15堆栈跟踪:#0/home/imran/projects/firstmobile/simple_client.php(15):SoapClient->__soapCall('geolocate',Array)#1{main}已抛出/home/imran/projects/firstmobile/simple_client.php,第15行

我认为错误在my_geo_soap_wrapper类中。如果我阅读了您的代码,并且错误正确,那么SOAP调用($client->__soapCall("geolocate",array($lat,$lng));)正在映射到SOAP服务器端的$soap_wrapper->geolocate($lat,$lng)

纯粹基于类的名称,我想知道这个"my_geo_soap_wrapper"类是否正在委托给其他对象,该对象也有一个名为geolocate的方法,而这就是bug所在的地方?例如

class my_geo_soap_wrapper
{
     function geolocate($lat,$lng)
     {
         // Will blow up if $this->delegated_object hasn't been set correctly
         return $this->delegated_object->geolocate($lat,$lng);
     }
}

纯粹的猜测,但可能会提出一条调查路线。