2012-02-03 13 views
8

Hi używam tego kodu na serwerze NuSOAP ale gdy zgłoszę serwer w przeglądarce internetowej pokazuje komunikat „Ta usługa nie zawiera opis Web” Oto kodNuSOAP prosty serwer

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

ramach pomocy ...

+1

Cóż, pan zapytać usługę WSDL do * do * niczego? Lub po prostu odwiedzić to w przeglądarce? Wszystko, co robi, to informowanie, że nie ma stron internetowych do wyświetlenia, ale jeśli wyślesz to SOAP, którego się spodziewasz, może to zadziała ... – DaveRandom

+0

Chcę po prostu pokazać xml z mojego pliku server.php –

Odpowiedz

15

Proszę zmienić swój kod,

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

zrobił zdefiniowaniu nazw ..

Zobacz prosty przykład tutaj: -

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

4

przeglądarka internetowa nie jest wywołanie usługi sieci Web - można utworzyć klienta 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); 

ta powinna wyświetlić Hello, StackOverFlow

Aktualizacja

Aby utworzyć WSDL trzeba dodać:

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

Można również użyć 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) 
?> 
Powiązane problemy