如何使用 Pear SOAP_Client 进行身份验证
我正在尝试从未启用 SoapClient 的服务器登录到我的 magento 的 Web 服务。所以我想我会安装并使用 Pear 的 SOAP_Client 但我不知道如何登录。
对于 SoapClient,我使用:
$client = new SoapClient($WSDL);
$session = $client->login($user, $api_key);
$response = $client->call($session, $method, $arguments);
但我找不到 SOAP_Client 的 login
方法的类似内容
我认为我应该在构造函数的 $proxy_params 中设置一些内容,但我找不到索引应该是。
$proxy_params = array();
$client = new SOAP_Client($wsdl, true, false, $proxy_params);
$client->call($method, $arguments)
I am trying to login to my magento's web services from a server that does not have SoapClient enabled. So I figured I would install and use Pear's SOAP_Client but I can't figure out how to login.
With SoapClient I use:
$client = new SoapClient($WSDL);
$session = $client->login($user, $api_key);
$response = $client->call($session, $method, $arguments);
But I can't find an analog to the login
method for SOAP_Client
I gather that I should be setting something in the $proxy_params of the constructor, but I can't find what the indexes should be.
$proxy_params = array();
$client = new SOAP_Client($wsdl, true, false, $proxy_params);
$client->call($method, $arguments)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我想通了,这里有几个因素。
SoapClient 没有登录函数,我调用的登录是 WSDL 中定义的调用
WSDL 中未定义各种 magento API 方法,您可以向 WSDL 定义为
call
的方法提供参数资源方法。这造成了一些混乱,因为使用$client->call()
似乎调用了 SOAP_Client 类定义的call
,所以我需要使用$ client->call('call')
调用 SOAP 方法call
最终代码为:
So I figured this out, and there are a couple of factors here.
There isn't a login function for SoapClient, the login I was calling is a call as defined in the WSDL
The various magento API methods are not defined in the WSDL, you provide an argument resource method to method defined as
call
by the WSDL. This created a bit of confusion because using$client->call()
seems to invokecall
as defined by the SOAP_Client class, so I need to use$client->call('call')
to invoke the SOAP methodcall
The final code ended up being: