[Web Service][SOAP] NuSOAP avec PHP
Bonjour,
Je souhaite utiliser la librairie NuSoap pour faire du service web. Pour faire un test de base j'utilise mes pages perso (free.fr) et je rencontre le problème suivant :
Citation:
Fatal error: Call to undefined function: call() in /mnt/107/sdc/a/1/kris.brau/index.php on line 15
Voici mon code :
index.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?php
require('nusoap-0.7.2/lib/nusoap.php');
echo"<h1>HELLO WORD</h1>";
$sel = new soapclient('http://kris.brau.free.fr/select.php');
$param = array(
'user' => 'BEB,
'pwd' => 'xxx',
'id' => 1
);
$results = $sel>call('people_select', $param); // Calls the method
print_r($results);
?> |
select.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <?php
require('nusoap-0.7.2/lib/nusoap.php');
$s = new soap_server;
$s -> register('people_select');
echo $s
function people_select($user, $pwd, $id)
{
if($user != "myuser" || $pwd != "mypwd") // Checks username/password
return new soap_fault("Client", "Login incorrect", "Bad value of params 'user' or 'pwd'");
if(empty($id))
return new soap_fault("Client", "Bad request", "'id' can't be empty");
$query = "SELECT name, age, city FROM people WHERE id = $id";
if(($conn = @mysql_connect("localhost", "root", "")) === FALSE)
return new soap_fault("Server", "MySQL", mysql_error());
if((@mysql_select_db("test", $conn)) === FALSE)
return new soap_fault("Server", "MySQL", mysql_error());
$res = @mysql_query($query, $conn);
if(mysql_num_rows($res) < 1) // Checks whether there are results
return new soap_fault("Server", "MySQL", "No results");
@mysql_close($conn);
/* Sends the results to the client */
$resp = @mysql_fetch_array($res, MYSQL_ASSOC);
$resp["time"] = time();
return $resp;
}
$s -> service($HTTP_RAW_POST_DATA); // Executes the RPC
?> |