nuSoap 函数不是有效方法
当尝试实例化我的 nuSoap
方法 authenticateUser
时,它说:
致命错误:未捕获的 SoapFault 异常:[Client] 函数(“authenticateUser”)不是 /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';
}
}
我认为有两件事会导致此错误:
更可能的是:我的函数注册在某种程度上不正确,即使 wsdl gui 显示该函数已正确注册并且我已经能够通过
SoapUI
程序成功使用该方法。不太可能:不知何故,该函数不再被破坏,但它被缓存了,所以我看到了一个旧错误。
问题:当尝试通过 PHP
使用此 soap
服务方法时,为什么我会收到输出错误,指出此函数不存在在服务上,什么时候才清楚呢?
When trying to instantiate my nuSoap
method authenticateUser
, it says:
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
But when I replace that method name for one that already works, everything works just fine. So I think the instantiation syntax isn't wrong.
/*-----------
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';
}
}
There are two things I can think of that would cause this error:
More likely: my registration of the function is somehow incorrect, even though the wsdl gui shows that the function is registered correctly and I've been able to successfully consume the method via the
SoapUI
program.Less likely: somehow, the function isn't broken anymore, but its cached and so I'm seeing an old error.
The Question: When trying to consume this soap
service method via PHP
, why do I get an output error stating that this function doesn't exist in the service, when it clearly is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您使用soap的每个文件中设置
,或设置
wsdl_cache_enabled
到
php.ini
文件中的0
。Set
In every file you use soap from, or set
wsdl_cache_enabled
to
0
in yourphp.ini
file.如果您在Linux上,也可以直接从/tmp/dir删除缓存的wsdl文件
If you are on Linux, you can also directly delete the cached wsdl file from /tmp/ dir
这是缓存!!!愚蠢的。我所要做的就是关闭电脑并上床睡觉。当我醒来时,我再次运行该文件,它非常有效。
这是 SOAP 服务中的函数第二次发生这种情况。
现在我需要知道如何清除肥皂服务的缓存。 (nuSoap)
It was the CACHE!!! stupid. All I had to do was close my computer and go to bed. When I woke up, I ran the file again and it worked like a charm.
This is the second time this has happened with a function in a SOAP service.
Now I need to know how to clear the cache of a soap service. (nuSoap)