php调用接口传参,PHP调用WEBSERVICE接口并传递参数

大家好,我碰到这样的问题,我在调用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);

代码有错吗? ???

回复讨论(解决方案)

大家碰到过这样的问题吗?

没有看到 WSDL 不能确定 DeductionIntegral 的参数应该是怎样的

但有一个原则是一定要遵守的:

如果直接方法名访问是这样的话 $client->DeductionIntegral($param)

那么用 call 方法访问就得这样 $client->call('DeductionIntegral',array($param))

即参数要放在数组中,因为其内部调用了 call_user_func_array 函数

没有看到 WSDL 不能确定 DeductionIntegral 的参数应该是怎样的

但有一个原则是一定要遵守的:

如果直接方法名访问是这样的话 $client->DeductionIntegral($param)

那么用 call 方法访问就得这样 $client->call('DeductionIntegral',array($param))

即参数要放在数组中,因为其内部调用了 call_user_func_array 函数 http://hr.pim-cs.com/WebService/IntegralInterface.asmx?wsdl,我直接用$client->call('DeductionIntegral',array($obj))这样子还是一样的错误提示,搞不懂呢!

没有看到 WSDL 不能确定 DeductionIntegral 的参数应该是怎样的

但有一个原则是一定要遵守的:

如果直接方法名访问是这样的话 $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));

他一共提供了2个方法

[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);

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值