Php 如何使用SoapClient将参数传递给函数?
不幸的是,我没有任何SOAP经验,请原谅我最终使用了错误的符号- 我得到了两个URL和一个XML字符串,我正在尝试从远程SOAP服务器获取XML响应 第一个URL是WSDL文档,我将其提供给构造函数:Php 如何使用SoapClient将参数传递给函数?,php,xml,soap,soap-client,Php,Xml,Soap,Soap Client,不幸的是,我没有任何SOAP经验,请原谅我最终使用了错误的符号- 我得到了两个URL和一个XML字符串,我正在尝试从远程SOAP服务器获取XML响应 第一个URL是WSDL文档,我将其提供给构造函数: $client = new SoapClient(URL_1, array('trace' => 1, 'exceptions' => 0)); 第二个URL是SOAP服务器,我在这里使用它: $client->__setLocation(URL_2); 这很有效,我可以通过
$client = new SoapClient(URL_1, array('trace' => 1, 'exceptions' => 0));
第二个URL是SOAP服务器,我在这里使用它:
$client->__setLocation(URL_2);
这很有效,我可以通过以下方式检索类型和函数:
以下是输出的有趣部分:
[28] => struct GetServiceInfo {
UserAuthentification UserAuthentification;
}
[74] => struct UserAuthentification {
string UserId;
string Password;
string SessionKey;
}
[3] => GetServiceInfoResponse GetServiceInfo(GetServiceInfo $parameters)
我的问题是调用上面的GetServiceInfo
函数
我收到了这个XML字符串,它与程序配合得很好:
但是得到错误:
Warning: SoapParam::SoapParam() expects parameter 2 to be string, array given in soap.php
Fatal error: SOAP-ERROR: Encoding: object has no 'UserAuthentification' property in soap.php
我想我遗漏了一些小东西,请帮忙
更新:
我进一步采取了以下步骤:
$user = array('UserId' => 'MY_USERNAME', 'Password' => 'MY_PASSWORD');
$params = array('UserAuthentification' => $user);
$result = $client->GetServiceInfo($params);
现在我得到一个错误:
Warning: SoapParam::SoapParam() expects parameter 2 to be string, array given in soap.php
Fatal error: SOAP-ERROR: Encoding: object has no 'UserAuthentification' property in soap.php
[FaultDescription]=>无法识别服务
[FaultReason]=>缺少wsa:To,并且给定的URL/服务可能会丢失
无法映射到现有服务
服务器使用WS-Addressing(FaultReason-关键字为
wsa:To
),这是常规PHP SoapClient扩展不支持的
我还没有使用WS-Addressing,但我最近正在分析一个API,用于我们将来将要进行的需要它的项目
请注意或注意哪些内容可能有用(搜索更多
PHP-WS-Addressing
)。同样,我只做过研究,没有任何实际操作经验来帮助您编写实际代码:)谢谢,我已经将您的建议传递给了我的同事,我自己没有太多时间来完成这项任务。
Warning: SoapParam::SoapParam() expects parameter 2 to be string, array given in soap.php
Fatal error: SOAP-ERROR: Encoding: object has no 'UserAuthentification' property in soap.php
$user = array('UserId' => 'MY_USERNAME', 'Password' => 'MY_PASSWORD');
$params = array('UserAuthentification' => $user);
$result = $client->GetServiceInfo($params);