2012-02-03 11 views
8

Hola estoy usando el código de servidor NuSOAP pero cuando llamo el servidor en el navegador web que muestre el mensaje "Este servicio no proporciona una descripción de la red" Aquí está el códigoNuSOAP servidores sencilla

<? 
//call library 
require_once ('lib/nusoap.php'); 

//using soap_server to create server object 
$server = new soap_server; 

//register a function that works on server 
$server->register('hello'); 

// create the function 
function hello($name) 
{ 
if(!$name){ 
return new soap_fault('Client','','Put your name!'); 
} 

$result = "Hello, ".$name; 
return $result; 
} 

// create HTTP listener 
$server->service($HTTP_RAW_POST_DATA); 

exit(); 
?> 

Una ayuda ...

+1

Bueno, ¿Le pidió el servicio WSDL para hacer * * nada? ¿O solo visítalo en un navegador? Todo lo que hace es decirle que no hay páginas web para servir, pero si envía un poco de SOAP que está esperando, quizás funcione ... – DaveRandom

+0

solo quiero mostrar xml desde mi archivo server.php –

Respuesta

15

Por favor, cambiar el código para,

<?php 
//call library 
require_once('nusoap.php'); 
$URL  = "www.test.com"; 
$namespace = $URL . '?wsdl'; 
//using soap_server to create server object 
$server = new soap_server; 
$server->configureWSDL('hellotesting', $namespace); 

//register a function that works on server 
$server->register('hello'); 

// create the function 
function hello($name) 
{ 
    if (!$name) { 
     return new soap_fault('Client', '', 'Put your name!'); 
    } 
    $result = "Hello, " . $name; 
    return $result; 
} 
// create HTTP listener 
$server->service($HTTP_RAW_POST_DATA); 
exit(); 
?> 

Usted aún Definir espacio de nombres ..

Por favor, vea un ejemplo simple aquí: -

http://patelmilap.wordpress.com/2011/09/01/soap-simple-object-access-protocol/

4

el navegador web no está llamando al servicio web - se puede crear un cliente PHP:

// Pull in the NuSOAP code 
require_once('lib/nusoap.php'); 
// Create the client instance 
$client = new soapclient('your server url'); 
// Call the SOAP method 
$result = $client->call('hello', array('name' => 'StackOverFlow')); 
// Display the result 
print_r($result); 

Esto debería mostrar Hello, StackOverFlow

actualización

Para crear un WSDL es necesario agregar lo siguiente:

$server->configureWSDL(<webservicename>, <namespace>); 
4

También puede utilizar nusoap_client

<?php 
// Pull in the NuSOAP code 
require_once('lib/nusoap.php'); 
// Create the client instance 
$client = new nusoap_client('your server url'); // using nosoap_client 
// Call the SOAP method 
$result = $client->call('hello', array('name' => 'Pingu')); 
// Display the result 
print_r($result) 
?>