使用 PHP5 的 XAMPP 上的 NuSOAP:无法打开流

发布于 2024-07-24 22:36:19 字数 3394 浏览 4 评论 0原文

大家好,我(又)遇到了问题。 这次我尝试使用 NuSoap w/ XAMPP 1.7.1,其中包括 PHP5 和 MySQL ...我写了一个肥皂客户端:

<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/mysql/helloworld2.php');
// Check for an error
$err = $client->getError();
if ($err) {
    // Display the error
    echo '<p><b>Constructor error: ' . $err . '</b></p>';
    // At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Doro'));
// Check for a fault
if ($client->fault) {
    echo '<p><b>Fault: ';
    print_r($result);
    echo '</b></p>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<p><b>Error: ' . $err . '</b></p>';
    } else {
        // Display the result
        print_r($result);
    }
}

?>

和我的肥皂服务器:

   // Enable debugging *before* creating server instance
   $debug = 1;
   // Create the server instance
   $server = new soap_server;
   // Register the method to expose
   $server->register('hello');

   // Define the method as a PHP function
   function hello($name) {

$dbhost = 'blah';
$dbuser = 'blub';
$dbpass = 'booboo';
try{
       $conn = MYSQL_CONNECT($dbhost, $dbuser, $dbpass) 
           or die ('Error connecting to mysql');

    if( !$conn ){
        return 'Hello, '.$name.' ...  too bad, I cannot connect to the db!';
    }
    else{
        $dbname = 'soaperina';
        MYSQL_SELECT_DB($dbname) or die('Error connecting to '.dbname);

        $queryres = @mysql_db_query(
                          'response',
                          'SELECT * FROM farben');

                    return 'RESPONSE: <br>';

                   while( $arr = mysql_fetch_array( $queryres ) ){
                         return $arr["ID"]." - ".$arr["Farben"]." - ".$arr["Rating"]."<br>";
                   }
            }
    }
    catch(Exception $e){
                 return 'Sorry, '.$name.', but that did not work at all!';
        }


   }
   // Use the request to (try to) invoke the service
   $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
   $server->service($HTTP_RAW_POST_DATA);
?>

我知道 PHP 可以工作,Apache 可以工作,MySQL 可以工作……它们也可以一起工作,但是当我尝试让它与 NuSOAP 一起工作时,它不起作用。 我得到以下信息:

警告: SoapClient::SoapClient(http://localhost/mysql/helloworld2.php) [soapclient.soapclient]:失败 开放流:Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle 没有最好的时间 Richtig Reagiert 帽子,或死 联合战争 费勒哈夫特,da der verbundene Host 没有反应的帽子。 在 C:\xampp\htdocs\mysql\helloworld2client.php 第 6 行

警告:SoapClient::SoapClient() [soapclient.soapclient]:I/O 警告: 加载外部实体失败 “http://localhost/mysql/helloworld2.php" 在 C:\xampp\htdocs\mysql\helloworld2client.php 第 6 行

致命错误:最大执行时间 超过 60 秒 C:\xampp\htdocs\mysql\helloworld2client.php 第 41 行

我不知道这是什么意思。 我希望你能帮忙!!! 提前谢谢:)

Hey guys, I have a problem (again). This time I am trying to use NuSoap w/ XAMPP 1.7.1 which includes PHP5 and MySQL ... I wrote a soap-client:

<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/mysql/helloworld2.php');
// Check for an error
$err = $client->getError();
if ($err) {
    // Display the error
    echo '<p><b>Constructor error: ' . $err . '</b></p>';
    // At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Doro'));
// Check for a fault
if ($client->fault) {
    echo '<p><b>Fault: ';
    print_r($result);
    echo '</b></p>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<p><b>Error: ' . $err . '</b></p>';
    } else {
        // Display the result
        print_r($result);
    }
}

?>

and my soap-server:

   // Enable debugging *before* creating server instance
   $debug = 1;
   // Create the server instance
   $server = new soap_server;
   // Register the method to expose
   $server->register('hello');

   // Define the method as a PHP function
   function hello($name) {

$dbhost = 'blah';
$dbuser = 'blub';
$dbpass = 'booboo';
try{
       $conn = MYSQL_CONNECT($dbhost, $dbuser, $dbpass) 
           or die ('Error connecting to mysql');

    if( !$conn ){
        return 'Hello, '.$name.' ...  too bad, I cannot connect to the db!';
    }
    else{
        $dbname = 'soaperina';
        MYSQL_SELECT_DB($dbname) or die('Error connecting to '.dbname);

        $queryres = @mysql_db_query(
                          'response',
                          'SELECT * FROM farben');

                    return 'RESPONSE: <br>';

                   while( $arr = mysql_fetch_array( $queryres ) ){
                         return $arr["ID"]." - ".$arr["Farben"]." - ".$arr["Rating"]."<br>";
                   }
            }
    }
    catch(Exception $e){
                 return 'Sorry, '.$name.', but that did not work at all!';
        }


   }
   // Use the request to (try to) invoke the service
   $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
   $server->service($HTTP_RAW_POST_DATA);
?>

I know that PHP works, the Apache works, MySQL works ... it also works together, but when I try to make it work with NuSOAP it does not work. I get following:

Warning:
SoapClient::SoapClient(http://localhost/mysql/helloworld2.php)
[soapclient.soapclient]: failed to
open stream: Ein Verbindungsversuch
ist fehlgeschlagen, da die Gegenstelle
nach einer bestimmten Zeitspanne nicht
richtig reagiert hat, oder die
hergestellte Verbindung war
fehlerhaft, da der verbundene Host
nicht reagiert hat. in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6

Warning: SoapClient::SoapClient()
[soapclient.soapclient]: I/O warning :
failed to load external entity
"http://localhost/mysql/helloworld2.php"
in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6

Fatal error: Maximum execution time of
60 seconds exceeded in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 41

I have no idea what that is supposed to mean. I hope ya'll can help!!! Thnx in advance :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

一个人的夜不怕黑 2024-07-31 22:36:19

我使用 NuSOAP 版本 1.7.3 和 PHP5。 在这个NuSOAP 1.7.3中,soapclient类被重命名为nu_soapclient。

你可以试试这个:

$client = new nusoap_client('http://localhost/mysql/helloworld2.php');

I used NuSOAP version 1.7.3 with PHP5. In this NuSOAP 1.7.3, soapclient class renamed by nu_soapclient.

You can try this:

$client = new nusoap_client('http://localhost/mysql/helloworld2.php');
最丧也最甜 2024-07-31 22:36:19

回答我自己的问题:nusoap 有一个 php5 问题...网上有一些答案和一些解决方案(不多),但它们对我不起作用。 我降级到 php4 并且工作正常......

to give an answer to my own question: nusoap has a problem with php5 ... there are some answers and some solutions on the net (not many), but they didn't work with me. I downgraded to php4 and it works fine ...

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