2012-02-03 15 views
8

Ciao io sto usando questo codice per il server nusoap ma quando chiamo il server nel browser web si vede il messaggio "Questo servizio non fornisce una descrizione Web" Ecco il codicenusoap semplice server

<? 
//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(); 
?> 

Un aiuto ...

+1

Beh, hai chiesto il servizio WSDL per fare * * qualcosa? O semplicemente visitarlo in un browser? Tutto quello che sta facendo è dirvi che non ci sono pagine web da servire, ma se si invia un SOAP che si aspetta, forse funzionerà ... – DaveRandom

+0

voglio solo mostrare xml dal mio file server.php –

risposta

15

Si prega di modificare il codice per,

<?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(); 
?> 

voi non ha ancora Definire namespace ..

Si prega di vedere un semplice esempio qui: -

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

4

il browser Web non sta chiamando il servizio Web - si potrebbe creare un client 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); 

Questo dovrebbe visualizzare Hello, StackOverFlow

Aggiornamento

Per creare un WSDL è necessario aggiungere il seguente:

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

È inoltre possibile utilizzare 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) 
?> 
Problemi correlati