大家好,我碰到这样的问题,我在调用websevice的时候,端口可以链接成功,但是一直显示
错误 :soap:Client: The request element was not recognized. 这个我该如何解决?$json='{"Request":{"Header":{"IFCode":"接口标识","CorpCode":"客户代码","SysCode":"KongRun_BasicCode","Account":"账号","Pwd":"密码"},"Body":{"Integral":"10","MobilePhone":"手机号码"}}}';
$obj=json_decode($json);
print_r($obj);
//$param=array('MobilePhone'=>$MobilePhone,'Integral'=>$Integral);
$result=$client->call('DeductionIntegral',array('parameters'=>$obj));
//print_r($param);
代码有错吗? ???
错误 :soap:Client: The request element was not recognized. 这个我该如何解决?$json='{"Request":{"Header":{"IFCode":"接口标识","CorpCode":"客户代码","SysCode":"KongRun_BasicCode","Account":"账号","Pwd":"密码"},"Body":{"Integral":"10","MobilePhone":"手机号码"}}}';
$obj=json_decode($json);
print_r($obj);
//$param=array('MobilePhone'=>$MobilePhone,'Integral'=>$Integral);
$result=$client->call('DeductionIntegral',array('parameters'=>$obj));
//print_r($param);
代码有错吗? ???
但有一个原则是一定要遵守的:
如果直接方法名访问是这样的话 $client->DeductionIntegral($param)
那么用 call 方法访问就得这样 $client->call('DeductionIntegral',array($param))
即参数要放在数组中,因为其内部调用了 call_user_func_array 函数
$json='{"Request":{"Header":{"IFCode":"接口标识","CorpCode":"客户代码","SysCode":"KongRun_BasicCode","Account":"账号","Pwd":"密码"},"Body":{"Integral":"10","MobilePhone":"手机号码"}}}'; $obj=json_decode($json); print_r($obj); //$param=array('MobilePhone'=>$MobilePhone,'Integral'=>$Integral); $result=$client->call('DeductionIntegral',array('parameters'=>$obj));
[0] => DeductionIntegralResponse DeductionIntegral(DeductionIntegral $parameters)
[1] => MemberAddIntegralResponse MemberAddIntegral(MemberAddIntegral $parameters)
DeductionIntegral 方法需要一个 DeductionIntegral 类型的数据作为参数而 DeductionIntegral 类型是这样描述的:
struct DeductionIntegral {
string Json;
}
所以应该这样调用
$param = array('Json' => $json);$client->call('DeductionIntegral',array($param));
或
$client->DeductionIntegral($param);