Hi,
I'm developing a SOAP server using nusoap.
I have a method with 3 input parameters: description, domainCode, date. I tested it with a client and everything worked fine.

But then I tested it with another client and I couldn't get a proper answer. After a lot of debugging I managed to figure out the problem: the second client I tested put the parameters in a different order: domainCode, description, date.

NuSoap seems to ignore array association, considering only the order parameters ar passed by.

This is what I did to fix the problem:
in the function invoke_method() you need to change the order of parameters' array() according to registerd method input.

function invoke_method() {
[...]
if (is_array($this->methodparams)) {
// --- new snippet --- //
$ordered_method_params = array();
foreach($this->operations[$this->methodname]['in'] as $key_param => $curent_param){
$ordered_method_params[$key_param] = $this->methodparams[$key_param];
}
$this->methodparams=$ordered_method_params;
// --------------------------------------- //
$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
} else {
$this->methodreturn = call_user_func_array($call_arg, array());
}
[...]
}

The new snippet can be used even in the case of an @eval invocation of method, some lines before the code example.

I hope someone can fix this bug in the official NuSoap release.

 
Last edit: Dott. Mario Mazza 2014-01-14