【问题标题】:nuSoap Function is Not a Valid methodnuSoap 函数不是有效的方法
【发布时间】:2011-06-30 16:58:34
【问题描述】:

当尝试实例化我的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';
    }
}

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

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

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

问题:当我尝试通过PHP 使用这个soap 服务方法时,为什么我得到一个输出错误,指出服务中不存在这个函数,当它很清楚时是吗?

【问题讨论】:

    标签: php soap wsdl nusoap


    【解决方案1】:

    设置

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

    在您使用soap的每个文件中,或设置wsdl_cache_enabled 到您的php.ini 文件中的0

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

    【讨论】:

    • 谢谢!我一直想弄清楚如何取消缓存。
    【解决方案2】:

    如果你是Linux,也可以直接从/tmp/dir中删除缓存的wsdl文件

    【讨论】:

      【解决方案3】:

      这是缓存!!!愚蠢的。我所要做的就是关上电脑上床睡觉。当我醒来时,我再次运行该文件,它就像一个魅力。

      这是 SOAP 服务中的函数第二次发生这种情况。

      现在我需要知道如何清除肥皂服务的缓存。 (nuSoap)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-26
        • 1970-01-01
        • 2018-10-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-03
        • 2012-02-17
        相关资源
        最近更新 更多