2010-11-18 34 views
4

Je suis en train de faire un service Web exemple avec NuSOAP en PHP, et je construit cette classe exemple:Aide NuSOAP pour un service Web

<?php 
// Pull in the NuSOAP code 
require_once('lib/nusoap.php'); 
// 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) { 
    return 'Hello, ' . $name; 
} 
// 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); 
?> 

et cette classe pour le client:

<?php 
// Pull in the NuSOAP code 
require_once('lib/nusoap.php'); 
// Create the client instance 
$client = new soapclient('http://localhost/webServiceResta.php'); 
// Call the SOAP method 
$result = $client->call('hello', array('name' => 'Scott')); 
// Display the result 
print_r($result); 
?> 

mais il me semble obtenir cette erreur, quand je lance le script:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/webServiceResta.php' : Start tag expected, '<' not found in /opt/lampp/htdocs/prueba.php:5 Stack trace: #0 /opt/lampp/htdocs/prueba.php(5): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in /opt/lampp/htdocs/prueba.php on line 5 

J'utilise XAMPP sur ubuntu, et tous les fichiers sont dans la plate-forme ht lieu.

+0

Il a été le code client, dans la nouvelle version, il a été renommé nusoap_client(); – Osukaa

Répondre

4

En utilisant nusoap de sorte que vous devez appeler nusoap_client :)

$client = new nusoap_client('http://localhost/webServiceResta.php');