Skip to content

Instantly share code, notes, and snippets.

@kopitar
Created September 18, 2018 12:14
Show Gist options
  • Save kopitar/e97d35506febcc1ecae68d1adcd894d4 to your computer and use it in GitHub Desktop.
Save kopitar/e97d35506febcc1ecae68d1adcd894d4 to your computer and use it in GitHub Desktop.
PHP: minimal example of SOAP Server and Client
<?php
// server
class MySoapServer
{
public function getMessage()
{
return 'Hello,World!';
}
public function addNumbers($num1,$num2)
{
return $num1+$num2;
}
}
$options= array('uri'=>'http://localhost/test');
$server=new SoapServer(NULL,$options);
$server->setClass('MySoapServer');
$server->handle();
// client
$options= array(
'location' => 'http://localhost/debug.php',
'uri' => 'http://localhost/everth'
);
$client=new SoapClient(NULL,$options);
echo $client->getMessage(); //Hello,World!
echo $client->addNumbers(3,5); // 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment