From: <joh...@at...> - 2003-09-21 14:31:56
|
Hi! I'm using nusoap for implementing a webservice client consuming an Axis webservice (running on Resin). I do have some problems when using wervices with multiple parameters. So far I've only been using one parameter as in wsdl information below; <wsdl:message name="findByKundnrRequest"> <wsdl:part name="in0" type="xsd:string"/> </wsdl:message> where I've used the following code for the parameters; $parameters = $intknr; This works fine. When using two parameters as in the wsdl below, the second parameter will be empty in the request. <wsdl:message name="insertRequest"> <wsdl:part name="in0" type="xsd:long"/> <wsdl:part name="in1" type="xsd:long"/> </wsdl:message> I've used the following code to define the parameters $params[0] = $intknr; $params[1] = $refid; I've succeeded in tracking the problem to the call function in the soap_client. The parameters are defined as follows function call($operation,$params=array(),$namespace='',$soapAction='',$headers=false,$rpcParams=null) The $params parameter is defined as an array and when using a single parameter the $params array translates to $params[0] = "xxxx" but when sending an array into the call function the array translates to $params[0].[0] = "xxxx" $params[0].[1] = "yyyy" $params[1] = "" and that fails as the array is one level too deep. I did a really small change to the code in the serializeRPCParameters function to just get me going, but that will probably make my future work fail as I'm going to use more complex parameters later on. The code added was; if (isset($parameters[$name])) { $this->debug('RPC:calling serializeType w/ named param'); $xml .= $this->serializeType($name, $type, $parameters[$name], $use); } elseif(is_array($parameters)) { $this->debug('THE ERROR IS HERE...RPC:calling serializeType w/ unnamed param'); // -->> QUICKFIX: If the array is too deep shift the array down one level... if(is_array($parameters[0])){ $parameters = $parameters[0]; } foreach ($parameters as $key=>$value){ $this->debug($type."--".$key."--".$value); } $xml .= $this->serializeType($name, $type, array_shift($parameters), $use); } else { $this->debug('no parameters passed.'); } This is probably just a simple newbie error, but I just can't figure out how to send the parameters... I'm using NuSoap 0.6.5 / PHP 4.3.2 / Apache2.0.46 / Win2000. I'll be happy to provide more information if needed! Regards, Johan Rosenquist |