Well I Decided to make a quick way to get a connection going...
Below is the relevant code with some comments; The basic idea is you create a class in a file of the same name with the prefix ws_. So if you made a payment class called Payment you would place it in a file called ws_Payment.php. the Class Payment will contain all the functions you want to use the file can contain any other code etc... etc..
after you create the class and save it in the correct location you will point your SOAP client to the url of the web service .../index.php?service=Payment
The WSDL is auto generated when you connect from a client as well as the server.
other then the files outlined below you will need to get WSDLCreator. I did not write this code but the author has a web site and has released it for free under GNU lesser GPL. WSDLCreator consists of 3 files you will need to create a free account with PHPClasses to download it or you can PM me your e-mail address and I will e-mail it to you.
http://www.protung.ro/
ws_init.php --------
//Set the Server up for dealing with XML and wsdl
ini_set("soap.wsdl_cache_enabled", "0");
header('Content-Type: text/xml; charset=UTF-8');
//Require configuration for outside enviornment
//This is not needed for the web service but your classes will need it so may as well include it here...
require('/freeway/admin/includes/configure.php');
//Require Class used to generate WSDL document
//Set Variables used as constants through out the web services system
$ws_request = 'service'; //-------> Used to coordinate the param passed throughout the ws system
$ws_host = 'http://localhost';
$ws_server = 'server.php';
$ws_wsdl = 'index.php';
$oe_includes_path = '/freeway/includes/';
$oe_admin_path = '/freeway/admin/includes/';
$oe_fun_path = '/freeway/admin/includes/functions/';
$load = isset($_REQUEST[$ws_request]) ? $_REQUEST[$ws_request] : 'default';
if($load != 'default'){
$load_class_file = 'ws_'.$load.'.php'; //-------> File contianing the class definition for requested service
$ws_path_sys = '/freeway/custom/webservices/'; //----> System Path
$ws_path_url = '/freeway/custom/webservices/'; //------------> URI Path
//Require the file containing the class definition of the requested service
require($ws_path_sys.$load_class_file);
}
end ws_init.php ---------
index.php ----------------
require('ws_init.php');
require('WSDLCreator.php');
if(is_file($load_class_file)){
$display = new WSDLCreator($load,$ws_path_url.$ws_wsdl.'?'.$ws_request.'='.$load);
$display->addFile($ws_path_sys.$load_class_file);
$display->addURLToClass($load, $ws_host.$ws_path_url.$ws_server.'?'.$ws_request.'='.$load);
$display->createWSDL();
$display->printWSDL();
}
else{
echo "You are not Authorized to View this Page";
}
end index.php ----------------
server.php --------------------
require('ws_init.php');
// Create the server
$server= new SoapServer($ws_host.$ws_path_url.$ws_wsdl.'?'.$ws_request.'='.$load, array('soap_version' => SOAP_1_2, 'encoding' => 'UTF-8', 'classmap' => $classmap));
$server->setClass($load); //-----> Add the requested Class functions to the Soap Server
$server->handle(); //--------------> Do it!
end server.php -----------------------------------
Make sure you read through the readme and examples in WSDLCreator here is an example class that demonstrates how to get an array back from your SOAP service:
class getData{
/**
* @return mixed
* */
function returnAll(){
$myvar = array("one", "two", "Three");
return $myvar;
}
}
!!!!! Take not that Comment is required for the WSDL Creator to work!!!!!
Php is loosely typed XML is not.