gpt4 book ai didi

php - nuSoap 函数不是有效方法

转载 作者:可可西里 更新时间:2023-11-01 00:06:53 26 4
gpt4 key购买 nike

当尝试实例化我的 nuSoap 方法 authenticateUser 时,它说:

Fatal error: Uncaught SoapFault exception: [Client] Function ("authenticateUser") is not a valid method for this service in /Applications/MAMP/htdocs/projo/dev/home.php:14

但是,当我将那个方法名称替换为已经有效的方法名称时,一切正常。所以我认为实例化语法没有错。

/*-----------
Authenticate User
------------*/
$server->register(
// method name
'authenticateUser',

// input parameters
array('sessionUserName' => 'xsd:string', 'sessionHash' => 'xsd:string', 'user' => 'xsd:string', 'pass' => 'xsd:string'),

// output parameters
array('return' => 'xsd:string'),

// namespace
$namespace,

// soapaction
$namespace . '#authenticateUser',

// style
'rpc',

// use
'encoded',

// documentation
'authenticates a user and returns a json array of the user info'
);

function authenticateUser($sessionUserName, $sessionHash, $user, $pass)
{
//Check to see if a countryCode was provided
if ($sessionUserName != '' && $sessionHash != '' && $user == $GLOBALS['wsUser'] && $pass == $GLOBALS['wsPass'])
{

$suid = 'AUTH'.$GLOBALS['guid'].'SESSION';


$database = new SQLDatabase();
$database->openConnection();
$database->selectDb();

//Query
$sql = "SELECT * FROM members WHERE member_email='" . $sessionUserName . "' LIMIT 1";

//Query MySQL
$return = $database->query($sql);
$userDetails = $database->fetch_array( $return );



if(!empty($userDetails)) {
$userDetails[0]['authSession'] = $suid;
$newArr = $userDetails[0];
$response = json_encode($newArr);
}

/*print $sql.'<br /><pre>';
print_r($response);
echo '</pre>';*/

//Throw SQL Errors
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}

//Return on Success
return $response;

//Close Connection
mysql_close($con);
}
else
{
return 'Error: You must supply all of the inputs!x';
}
}

我能想到有两件事会导致这个错误:

  1. 更有可能:我的函数注册在某种程度上是不正确的,即使 wsdl gui 显示该函数已正确注册并且我已经能够通过SoapUI 程序。

  2. 不太可能:不知何故,函数不再被破坏,但它被缓存了,所以我看到了一个旧错误。

问题:当尝试通过 PHP 使用此 soap 服务方法时,为什么我会收到一个输出错误,指出此函数不可用'存在于服务中,当它明显存在时?

最佳答案

设置

ini_set("soap.wsdl_cache_enabled", "0"); 

在您使用 soap 的每个文件中,或设置 wsdl_cache_enabledphp.ini 文件中设置为 0

[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=0

关于php - nuSoap 函数不是有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6538346/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com