NuSOAP su XAMPP con PHP5: impossibile aprire lo stream
Domanda
Ciao ragazzi, ho un problema (di nuovo). Questa volta sto cercando di usare NuSoap con XAMPP 1.7.1 che include PHP5 e MySQL ... Ho scritto un 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);
}
}
?>
e il mio 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);
?>
So che PHP funziona, Apache funziona, MySQL funziona ... funziona anche insieme, ma quando provo a farlo funzionare con NuSOAP non funziona. Ottengo seguente:
Attenzione: SoapClient :: SoapClient ( http: //localhost/mysql/helloworld2.php ) [soapclient.soapclient]: impossibile flusso aperto: 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. nel C: \ xampp \ htdocs \ mysql \ helloworld2client.php sulla linea 6
Avvertenza: SoapClient :: SoapClient () [soapclient.soapclient]: Avviso I / O: impossibile caricare entità esterna " http: //localhost/mysql/helloworld2.php " nel C: \ xampp \ htdocs \ mysql \ helloworld2client.php sulla linea 6
Errore irreversibile: tempo di esecuzione massimo di 60 secondi superati in C: \ xampp \ htdocs \ mysql \ helloworld2client.php sulla linea 41
Non ho idea di cosa significhi. Spero che tu possa aiutarti !!! Grazie in anticipo :)
Soluzione 2
per dare una risposta alla mia domanda: nusoap ha un problema con php5 ... ci sono alcune risposte e alcune soluzioni in rete (non molte), ma non hanno funzionato con me. Ho effettuato il downgrade a php4 e funziona benissimo ...
Altri suggerimenti
Ho usato NuSOAP versione 1.7.3 con PHP5. In questo NuSOAP 1.7.3, classe soapclient rinominata da nu_soapclient.
Puoi provare questo:
$client = new nusoap_client('http://localhost/mysql/helloworld2.php');