NuSOAP en XAMPP con PHP5: no se pudo abrir la secuencia
Pregunta
Hola chicos, tengo un problema (de nuevo). Esta vez estoy tratando de usar NuSoap con XAMPP 1.7.1 que incluye PHP5 y MySQL ... Escribí un cliente de jabón:
<?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);
}
}
?>
y mi servidor de jabón:
// 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);
?>
Sé que PHP funciona, Apache funciona, MySQL funciona ... también funciona en conjunto, pero cuando trato de hacerlo funcionar con NuSOAP no funciona. Recibo lo siguiente:
Advertencia: SoapClient :: SoapClient ( http: //localhost/mysql/helloworld2.php ) [soapclient.soapclient]: no se pudo flujo abierto: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die guerra hergestellte Verbindung fehlerhaft, da der verbundene Anfitrión nicht reagiert hat. en C: \ xampp \ htdocs \ mysql \ helloworld2client.php en la línea 6
Advertencia: SoapClient :: SoapClient () [soapclient.soapclient]: advertencia de E / S: no se pudo cargar la entidad externa " http: //localhost/mysql/helloworld2.php " en C: \ xampp \ htdocs \ mysql \ helloworld2client.php en la línea 6
Error fatal: tiempo máximo de ejecución de 60 segundos excedidos en C: \ xampp \ htdocs \ mysql \ helloworld2client.php en la línea 41
No tengo idea de lo que se supone que significa eso. Espero que puedan ayudar !!! Gracias de antemano :)
Solución 2
para responder a mi propia pregunta: nusoap tiene un problema con php5 ... hay algunas respuestas y algunas soluciones en la red (no muchas), pero no funcionaron conmigo. Bajé a php4 y funciona bien ...
Otros consejos
Utilicé NuSOAP versión 1.7.3 con PHP5. En este NuSOAP 1.7.3, clase de soapclient renombrada por nu_soapclient.
Puedes probar esto:
$client = new nusoap_client('http://localhost/mysql/helloworld2.php');