I don't know why you get an error message, but I have been playing around with the same thing and this code works for me. Just update the location in $options and make sure that the Test class is included in the server file.
Client:
PHP Code:
<?php
$options = array(
'location'=>'http://localhost/akkreditering/wwwdocs/soap/server.php',
'uri'=>'http://localhost/akkreditering/wwwdocs/soap/server/',
);
try {
$client = new SoapClient(null,$options);
echo $client->getString();
}
catch ( SoapFault $e ){
echo $e->getMessage();
}
?>
Server:
PHP Code:
<?php
$options = array('uri' => 'http://localhost/akkreditering/wwwdocs/soap/server/');
$server = new SoapServer(null,$options);
$server->setClass('Test');
$server->handle();
?>
Test class:
PHP Code:
<?php
class Test{
public function getString(){
return 'Hello World!!';
}
}
?>
Bookmarks