我试图用NuSoap创建一个简单的php Soap(服务器和客户端)。
HelloServer.php
<?php
//call library
require_once ('lib/nusoap.php');
$URL = "http://www.mm-due.dk/WebServiceSOAP/server.php";
$namespace = $URL . '?wsdl';
//using soap_server to create server object
$server = new soap_server;
$server->configureWSDL('server', $namespace);
function hello($someone) {
return "Hello " . $someone . "!";
}
//register a function that works on server
$server->register('hello');
$server->service($HTTP_RAW_POST_DATA);
$server->handle();
exit();
?>
您可以在http://www.mm-due.dk/WebServiceSOAP/HelloServer.php
上查看服务器HelloClient.php
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Hello</h1>
<?php
require_once ('lib/nusoap.php');
$client = new SoapClient(null, array(
'location' => "http://www.mm-due.dk/WebServiceSOAP/HelloServer.php?wsdl",
'uri' => "urn://www.herong.home/req",
'trace' => 1 ));
$return = $client->__soapCall("hello",array("Ole"));
?>
<p>Returning value of __soapCall() call: <?php echo $return; ?></p>
<p>Dumping request headers: <?php echo $client->__getLastRequestHeaders(); ?></p>
<p>Dumping request: <?php echo $client->__getLastRequest(); ?></p>
<p>Dumping response headers: <?php echo $client->__getLastResponseHeaders(); ?></p>
<p>Dumping response: <?php echo $client->__getLastResponse(); ?></p>
</body>
</html>
您可以在http://www.mm-due.dk/WebServiceSOAP/HelloClient.php
看到客户我想从我的服务器返回值,所以结果应该是这样的:
Returning value of __soapCall() call: Hello Ole!
我做错了什么?