PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » SOAP » Bug #2836

Request-Parameter-Failure, Order must be like in wsdl

Details

Submitted2004-11-26 20:55 UTC
Frompear dot php dot net at inxon dot de
Assignedyunosh
StatusBogus
PackageSOAP
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2004-11-26 20:55 UTC] pear dot php dot net at inxon dot de

Description:
------------
There's a generic Bug in the Server.php:

...
function &callMethod($methodname, &$args) {
...
if ($args) {
// call method with parameters
if (isset($this->soapobject) && is_object($this->soapobject)) {
if (is_object($args) || is_array($args) /* || is_resource($args) */ ) { // hash needed?
$args = array($args); // put hash $args in an array
} // if
$ret = @call_user_func_array(array(&$this->soapobject, $methodname), $args);
...

Additionally, all dispatched functions have to look like this:
function divide($in) // new: array/hash
{
$dividend = $in['dividend']; // new
$divisor = $in['divisor']; // new
// the soap server would normally catch errors like this
// and return a fault, but this is how you do it yourself.
if ($divisor == 0)
return new SOAP_Fault('You cannot divide by zero', 'Client');
else
return $dividend / $divisor;
}

Reproduce code:
---------------
In the examples-directory is an example_server.php with an SOAP-operation called "division". If you call this operation you need to send two parameters:
divisor
dividend
e.g.
<ns4:divide>
<dividend xsi:type="xsd:int">2</dividend>
<divisor xsi:type="xsd:int">4</divisor></ns4:divide>
Now, if you change the order, you will get wrong results:
<ns4:divide>
<divisor xsi:type="xsd:int">4</divisor>
<dividend xsi:type="xsd:int">2</dividend></ns4:divide>

[2004-11-26 20:58 UTC] pear dot php dot net at inxon dot de

[Description] The description is a solution for the problem.

The based problem is: if you use the SOAP::Server, Requests have to be in the same order as they are in the wsdl - parameters are not called by reference but by the position.