sarnath
Legacy Member
Ik zou graag een simpel scriptje maken dat via SOAP een bepaalde string teruggeeft.
Nu heb ik na heel wat opzoekwerk een goed voorbeeld gevonden, maar krijg het niet aan de praat en vind niet direct fouten.
Ik heb dus een server.php en een client.php met het gebruik van een class (API.php):
server.php:
client.php:
en de file API.php (classes/API.php):
de fout die ik krijg is de volgende:
Iemand een idee?
Nu heb ik na heel wat opzoekwerk een goed voorbeeld gevonden, maar krijg het niet aan de praat en vind niet direct fouten.
Ik heb dus een server.php en een client.php met het gebruik van een class (API.php):
server.php:
Code:
<?php
// require the class that will handle the calls
require_once 'classes/API.php';
// disable the soap.wsdl_cache
ini_set("soap.wsdl_cache_enabled", "0");
// get RAW_POST_DATA
if(!isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = file_get_contents('php://input');
// set options for the server
$options = array('uri' => 'http://localhost/SOAP/');
// init server
$server = new SoapServer(null, $options);
// set the class that will handle the SOAP-requests
$server->setClass('API');
// handle SOAP-requests
$server->handle();
?>
client.php:
Code:
<?php
$options = array('location' => 'http://localhost/SOAP/server.php', 'uri' => 'http://localhost/SOAP/');
try {
// init client
$client = new SoapClient(null, $options);
// make SOAP-request and print it
echo '<pre>';
echo "\n".$client->sayHello();
echo '</pre>';
}
// catch SOAP-errors
catch(SoapFault $e)
{
// print error
print_r($e);
}
?>
en de file API.php (classes/API.php):
Code:
<?php
class API{
public function sayHello()
{
return 'Hello World';
}
}
?>
de fout die ik krijg is de volgende:
Code:
SoapFault Object
(
[message:protected] => looks like we got no XML document
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/SOAP/client.php
[line:protected] => 8
[trace:Exception:private] => Array
(
[0] => Array
(
[function] => __call
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => sayHello
[1] => Array
(
)
)
)
[1] => Array
(
[file] => /var/www/SOAP/client.php
[line] => 8
[function] => sayHello
[class] => SoapClient
[type] => ->
[args] => Array
(
)
)
)
[previous:Exception:private] =>
[faultstring] => looks like we got no XML document
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
Iemand een idee?