sugarcrm:无法通过扩展现有Web服务从自定义soap服务调用登录
我遵循本教程扩展Sugarcrm Web服务,为我的自定义模块定义新服务。 问题:但是,作为初步检查,我尝试调用现有的登录服务,但它本身失败了。请帮助指出问题所在。我被卡住了 我的教程如下: 正如在教程中提到的,我在custom/service/v4\u 1\u custom文件夹中创建了以下文件 registry.phpsugarcrm:无法通过扩展现有Web服务从自定义soap服务调用登录,sugarcrm,Sugarcrm,我遵循本教程扩展Sugarcrm Web服务,为我的自定义模块定义新服务。 问题:但是,作为初步检查,我尝试调用现有的登录服务,但它本身失败了。请帮助指出问题所在。我被卡住了 我的教程如下: 正如在教程中提到的,我在custom/service/v4\u 1\u custom文件夹中创建了以下文件 registry.php <?php require_once('service/v4_1/registry.php'); class registry_v4_1_custom extends
<?php
require_once('service/v4_1/registry.php');
class registry_v4_1_custom extends registry_v4_1
{
protected function registerFunction()
{
parent::registerFunction();
$this->serviceClass->registerFunction('my_get_orders',
array(
'session' => 'xsd:string',
'module_name' => 'xsd:string',
'id' => 'xsd:string',
),
array(
'return' => 'xsd:string',
)
);
}
}
?>
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
chdir('../../..');
require_once('SugarWebServiceImplv4_1_custom.php');
$webservice_class = 'SugarSoapService2';
$webservice_path = 'service/v2/SugarSoapService2.php';
$registry_class = 'registry_v4_1_custom';
$registry_path = 'custom/service/v4_1_custom/registry.php';
$webservice_impl_class = 'SugarWebServiceImplv4_1_custom';
$location = 'custom/service/v4_1_custom/soap.php';
require_once('service/core/webservice.php');
?>
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('service/v4_1/SugarWebServiceImplv4_1.php');
class SugarWebServiceImplv4_1_custom extends SugarWebServiceImplv4_1
{
/*
* Returns the id if authenticated
*
* @param id
* @return string $session - false if invalid.
*
*/
function my_get_orders($session, $module_name, $id)
{
$GLOBALS['log']->info('Begin: SugarWebServiceImplv4_1_custom->my_get_orders');
$error = new SoapError();
//authenticate
if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error))
{
$GLOBALS['log']->info('End: SugarWebServiceImplv4_1_custom->my_get_orders.');
return false;
}
return $id;
}
}
?>
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('../include/nusoap/nusoap.php'); //must also have the nusoap code on the ClientSide.
$user_name ='myuser';
$user_password = 'mypassword';
$hostname = 'http://127.0.0.1/sugarcrm/custom/service/v4_1_custom/soap.php?wsdl';
// Create the SOAP client instance
$soapclient = new nusoapclient($hostname, true);
// Login to the server
echo '<b>LOGIN:</b><BR>';
$result = $soapclient->call('login',array('user_auth'=>array('user_name'=>$user_name,'password'=>md5($user_password), 'version'=>'.01'), 'application_name'=>'SoapTest'));
echo '<BR><BR><b>HERE IS RESULT:</b><BR>';
echo print_r($result);
echo var_dump($result);
$session = $result['id'];
echo "sessionid is ".$session;
?>
我将同一组文件放在service/custom下[现有版本直接在service/eg:service/v4\u 1下] 现在它可以工作了,所以之前的情况是文件路径解决问题
HERE IS RESULT:
1
boolean false
sessionid is