I use NuSoap server in WSDL mode and php Classes for data retrieval.
NuSoap has ability to instantiate classes but this requires Class.method notation which in my case means there has to be Class.method notation also in WSDL which I would like to get rid of.
I have modified my NuSoap source so that you can set Class on server without the need of Class.method notation.
Here are the suggested changes:
Add instance variable:
var $userclass = null;
Add method:
public function setClass($class) {
$this->userclass = $class;
}
Add function invoke_method():
After the lines (3995-3996 in 0.9.5):
$class = '';
$method = '';
These lines:
if (!empty($this->userclass)) {
$class = $this->userclass;
$method = $this->methodname;
}
These changes shouldn't break existing functionality but would allow setting class on server instance without having to use Class.method notation on WSDL.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will be adding a more general capability, specifically a dispatch map. This will allow the specification of a function, class+method or class-instance+method for any soap-action or operation name. The implicit mapping done today will be the default if no appropriate map element is present for a particular call.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've added the method below to my working copy and check the maps when invoking a method on the server, but have not created full tests so have not committed. If there is something in this code that looks bad or that you would like to see added, let me know.
/** * add an operation dispatch mapping * * (either $operation_element OR $soap_action should be specified) * (one or neither of $invoke_class or $invoke_class_instance should be specified) * * @param string $operation_element The XML element for the operation * @param string $soap_action The SOAP Action for the operation * @param string $invoke_class The class on which to invoke as a class method * @param string $invoke_class_instance The class on which to invoke as an instance method * @param string $invoke_function The function or method to invoke * @return boolean true if added, false if not * @access public */functionaddDispatchMap($operation_element,$soap_action,$invoke_function,$invoke_class,$invoke_class_instance){//massageparametersif(!is_string($operation_element))$operation_element='';if(!is_string($soap_action))$soap_action='';if(!is_string($invoke_class))$invoke_class='';if(!is_string($invoke_class_instance))$invoke_class_instance='';if(!is_string($invoke_function))$invoke_function='';//validateparametersif($operation_element==''&&$soap_action==''){$this->debug('addDispatchMap:Neitheroperation_elementnorsoap_actionspecified'); return false; } if ($operation_element != '' && $soap_action != '') { $this->debug('addDispatchMap:Bothoperation_elementandsoap_actionspecified'); return false; } if ($invoke_class != '' && $invoke_class_instance != '') { $this->debug('addDispatchMap:Bothinvoke_classandinvoke_class_instancespecified'); return false; } if ($invoke_function == '') { $this->debug('addDispatchMap:Novalueprovidedforinvoke_function'); return false; } $map['operation_element'] = $operation_element; $map['soap_action'] = $soap_action; $map['invoke_class'] = $invoke_class; $map['invoke_class_instance'] = $invoke_class_instance; $map['invoke_function'] = $invoke_function; if ($operation_element != ''){$this->dispatchMapByOperationElement[$operation_element]=$map;$this->debug("addDispatchMap:Addedmapforoperation_element$operation_element"); } else { $this->dispatchMapBySOAPAction[$soap_action] = $map; $this->debug("addDispatchMap:Addedmapforsoap_action$soap_action");}returntrue;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not so sure this would work with my case.
Here's an example how I'm using it now with my setClass() -method.
/*Require PHP Class with business logic $WS_CLASS_DIR is directory from general configuration file and $WS_NAME comes from service specific configuration file read by a parameter submitted in the URL request.*/require_once($WS_CLASS_DIR.$WS_NAME.'.php');/*WSDL file is generated on the fly, from the service specific configuration file, and set here for the service.*/$wsdlfile=$WS_WSDL_DIR.$WS_NAME.'.wsdl';/*Initialize NuSoap server in WSDL-mode*/$server=newnusoap_server($wsdlfile);$server->soap_defencoding="utf-8";/*Set the class to be used by server.*/$server->setClass($WS_NAME);/*Get raw post data.*/if(!isset($HTTP_RAW_POST_DATA)){$HTTP_RAW_POST_DATA=file_get_contents('php://input');}$HTTP_RAW_POST_DATA = isset ( $HTTP_RAW_POST_DATA ) ? $HTTP_RAW_POST_DATA : '';/*Serve.*/$server->service($HTTP_RAW_POST_DATA);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use NuSoap server in WSDL mode and php Classes for data retrieval.
NuSoap has ability to instantiate classes but this requires Class.method notation which in my case means there has to be Class.method notation also in WSDL which I would like to get rid of.
I have modified my NuSoap source so that you can set Class on server without the need of Class.method notation.
Here are the suggested changes:
Add instance variable:
var $userclass = null;
Add method:
public function setClass($class) {
$this->userclass = $class;
}
Add function invoke_method():
After the lines (3995-3996 in 0.9.5):
$class = '';
$method = '';
These lines:
if (!empty($this->userclass)) {
$class = $this->userclass;
$method = $this->methodname;
}
These changes shouldn't break existing functionality but would allow setting class on server instance without having to use Class.method notation on WSDL.
I will be adding a more general capability, specifically a dispatch map. This will allow the specification of a function, class+method or class-instance+method for any soap-action or operation name. The implicit mapping done today will be the default if no appropriate map element is present for a particular call.
That's nice, any estimate about timetable on this?
I've added the method below to my working copy and check the maps when invoking a method on the server, but have not created full tests so have not committed. If there is something in this code that looks bad or that you would like to see added, let me know.
I'm not so sure this would work with my case.
Here's an example how I'm using it now with my setClass() -method.