嘿伙计们,我有问题(再次)。这次我试图使用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   nach einer bestimmten Zeitspanne nicht   富裕的帽子,奥德死了   hergestellte Verbindung战争   fehlerhaft,da der verbundene主持人   nicht reagiert帽子。在   C:\ XAMPP \ htdocs中\ mysql的\ helloworld2client.php   在第6行

     

警告:SoapClient :: SoapClient()   [soapclient.soapclient]:I / O警告:   无法加载外部实体   “ http://localhost/mysql/helloworld2.php &quot;   在   C:\ XAMPP \ htdocs中\ mysql的\ helloworld2client.php   在第6行

     

致命错误:最长执行时间   超过60秒   C:\ XAMPP \ htdocs中\ mysql的\ helloworld2client.php   在第41行

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

有帮助吗?

解决方案 2

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

其他提示

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

你可以试试这个:

$client = new nusoap_client('http://localhost/mysql/helloworld2.php');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top