[eluser]Kyle Johnson[/eluser]
What's up everyone?
I'm trying to set up a new version of some web services, but want to ensure that anyone using the previous version is still able to. Can anyone point me in the right direction? When I started the project I included the version in the uri segment, but now I'm not entirely sure how to call the function that is supposed to be for a different version.
Code:
public function RequestService() {
switch ($this->uri->segment(3)) {
case 'v1':
try {
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer(base_url() . 'wsdl/RequestService_v1.wsdl', array(
'soap_version' => SOAP_1_2));
//$server->setClass("Wsvc");
$server->setObject($this);
$server->handle();
} catch (SoapFault $exception) {
echo $exception;
}
break;
case 'v2':
try {
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer(base_url() . 'wsdl/RequestService_v2.wsdl', array(
'soap_version' => SOAP_1_2));
//$server->setClass("Wsvc");
$server->setObject($this);
$server->handle();
} catch (SoapFault $exception) {
echo $exception;
}
break;
default:
;
break;
}
}
The part I'm not sure about is how to make $server->handle() call the proper version of the function. Once the data gets passed to the function I have access to the data object, and can call different methods from within, but this means updating the WSDL with a new element for versioning.
So if for example, the wsdl has a CreateRequest method I could do something like this:
Code:
public function CreateRequest($data) {
if(isset($data->Version->MajorVersion))
{
switch ($data->Version->MajorVersion) {
case '2':
return _createRequest_v2($data);
break;
}
} else {
// assume old version
// do stuff
}
}
Or is there a better way to facilitate this?