[英]NuSOAP on XAMPP with PHP5: failed to open stream
大家好,我又遇到了問題。 這次,我嘗試使用帶有XAMPP 1.7.1的NuSoap(包括PHP5和MySQL)...我編寫了一個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);
}
}
?>
和我的肥皂服務器:
// 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,Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat,或其他hergestelltete Verbindung戰爭征兵,動詞主持人nicht reagiert帽子。 在第6行的C:\\ xampp \\ htdocs \\ mysql \\ helloworld2client.php中
警告:SoapClient :: SoapClient()[soapclient.soapclient]:I / O警告:無法在C:\\ xampp \\ htdocs \\ mysql \\ helloworld2client.php中加載外部實體“ http://localhost/mysql/helloworld2.php ”在第6行
致命錯誤:第41行的C:\\ xampp \\ htdocs \\ mysql \\ helloworld2client.php中超過60秒的最大執行時間
我不知道那是什么意思。 希望您能幫上忙!!! 提前Thnx :)
我在PHP5上使用了NuSOAP版本1.7.3。 在此NuSOAP 1.7.3中,soapclient類由nu_soapclient重命名。
您可以嘗試以下方法:
$client = new nusoap_client('http://localhost/mysql/helloworld2.php');
給出我自己的問題的答案:nusoap的php5有問題...網絡上有一些答案和一些解決方案(數量不多),但它們與我不兼容。 我降級到php4,它可以正常工作...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.