nuSoap 函数不是有效方法

发布于 2024-11-17 20:07:25 字数 2521 浏览 5 评论 0原文

当尝试实例化我的 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 服务方法时,为什么我会收到输出错误,指出此函数不存在在服务上,什么时候才清楚呢?

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:

  1. 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.

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

新人笑 2024-11-24 20:07:25

在您使用soap的每个文件中设置

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

,或设置wsdl_cache_enabled
php.ini 文件中的 0

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

Set

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

In every file you use soap from, or set wsdl_cache_enabled
to 0 in your php.ini file.

[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=0
入画浅相思 2024-11-24 20:07:25

如果您在Linux上,也可以直接从/tmp/dir删除缓存的wsdl文件

If you are on Linux, you can also directly delete the cached wsdl file from /tmp/ dir

一花一树开 2024-11-24 20:07:25

这是缓存!!!愚蠢的。我所要做的就是关闭电脑并上床睡觉。当我醒来时,我再次运行该文件,它非常有效。

这是 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文