header("content-type:text/html;charset=utf-8"); try { $client = new SoapClient("http://xxx?wsdl" ); // print_r($client->__getFunctions()); // print_r($client->__getTypes()); $customerCode = 'wwggr'; $sign = Md5(date('Ymd',time()).$customerCode); $param = array( 'factoryCode' => '1244', .... 'product'=>['quantity'=>1,'sku'=>'4D5100126005'], .... ); $param = json_encode($param,JSON_UNESCAPED_UNICODE); print_r($param); // die; // $result = $client->__soapCall('AddOEMOrder',array("parameters"=>$param)); $result = $client->AddOEMOrder(['model'=>$param]); //print_r($result); //将stdclass object的$result转换为array $result = get_object_vars($result); //输出结果 echo $result["AddOEMOrderResult"]; } catch (SOAPFault $e) { print $e; }
服务器无法处理请求。 ---> 值不能为 null。
参数名: value
1.传入的参数为空
通过打印print_r($client->__getFunctions()); print_r($client->__getTypes());得知调用 AddOEMOrder 函数需要传入string类型的model变量,如果没有传入model变量则会出现上述问题
Array ( [0] => AddOEMOrderResponse AddOEMOrder(AddOEMOrder $parameters) [1] => AddOEMOrderResponse AddOEMOrder(AddOEMOrder $parameters) ) Array ( [0] => struct AddOEMOrder { string model; } [1] => struct AddOEMOrderResponse { string AddOEMOrderResult; } )
例如:$result = $client->AddOEMOrder(['model'=>$param]); 是调用成功的,
而 $result = $client->AddOEMOrder(['modl'=>$param]);则会出现上述问题