Soap ile servis oluşturmaya çalışırken nusoap içinde bulduğum örneklerden biri
<?php
// NuSoap'ı ekliyoruz...
require_once('nusoap/lib/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello', // method name
array('name' => 'xsd:string','name2' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);
//Register topla
$server->register('topla', // method name
array('name' => 'xsd:int','name2' => 'xsd:int'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#topla', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);
// Define the method as a PHP function
function hello($name,$name2) {
return 'Hello, ' . $name . $name2;
}
function topla($name,$name2) {
return $name + $name2;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>Eğer serverda soap aktif ise;<?php
// Servis adresimiz
$client = new SoapClient("http://localhost/service.php?wsdl");
$deg = $client->hello("bilmemne","...");
echo $deg;
?>