<?php
/*
* PHP SOAP - How to create a SOAP Server and a SOAP Client
*/
class MyAPI {
function test() {
return "Hello";
}
function login($username,$password) {
if($username != "" && $password!="") {
return $username;
} else {
return false;
}
}
}
//when in non-wsdl mode the uri option must be specified
$options=array('uri'=>'http://localhost/farid/soap/');
//create a new SOAP server
$server = new SoapServer(NULL,$options);
//attach the API class to the SOAP Server
$server->setClass('MyAPI');
//start the SOAP requests handler
$server->handle();
<?php
/*
* PHP SOAP - How to create a SOAP Server and a SOAP Client
*/
$options = array('location' => 'http://localhost/farid/soap/server.php',
'uri' => 'http://localhost/farid/soap/');
//create an instante of the SOAPClient (the API will be available)
$api = new SoapClient(NULL, $options);
//call an API method
echo $api->test();
<?php
$client = new SoapClient("http://webservice.smsline.ir/index.php?wsdl");
foreach($client->__getFunctions() as $item)
echo $item."<br>";
$var = array('username'=>'hetg2','password'=>'something');
$exception = null;
try {
$tmp =$client->COUNT_SENDSMS($var);
echo $tmp;
echo("<br>");
echo "Response:\n" . $client->__getLastResponse() . "\n";
} catch (SoapFault $sf) {
echo $sf;
}
BY: Farid Ahmadian
TAG: php, soap
DATE: 2013-01-1 00:00:01
With many thanks and best wishes for dear Pejman Moghadam, someone who taught me alot in linux and life :)