- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
很遗憾,我没有任何 SOAP 经验,请原谅我最终在下面使用了错误的符号 -
我得到了 2 个 URL 和一个 XML 字符串,我正在尝试从远程 SOAP 服务器获取 XML 响应。
第一个 URL 是一个 WSDL 文档,我将它提供给 SoapClient构造函数:
$client = new SoapClient(URL_1, array('trace' => 1, 'exceptions' => 0));
第二个 URL 是 SOAP 服务器,我在这里使用它:
$client->__setLocation(URL_2);
这很好用,我可以通过以下方式检索类型和函数:
print_r( $client->__getTypes() );
print_r( $client->__getFunctions() );
这是输出中有趣的部分:
[28] => struct GetServiceInfo {
UserAuthentification UserAuthentification;
}
[74] => struct UserAuthentification {
string UserId;
string Password;
string SessionKey;
}
[3] => GetServiceInfoResponse GetServiceInfo(GetServiceInfo $parameters)
我的问题是调用上面的 GetServiceInfo
函数。
我得到了这个与 SoapUi 配合良好的 XML 字符串程序:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://...../V1">
<soap:Header>.....</soap:Header>
<soap:Body>
<v1:GetServiceInfo>
<UserAuthentification>
<UserId>MY_USERNAME</UserId>
<Password>MY_PASSWORD</Password>
</UserAuthentification>
</v1:GetServiceInfo>
</soap:Body>
</soap:Envelope>
请问如何在我的 PHP 脚本中传递此参数?
我试过:
$result = $client->GetServiceInfo(array(
new SoapParam( "UserAuthentification", array( # ERROR, WANTS STRING HERE
new SoapParam( "UserId", "MY_USERNAME" ),
new SoapParam( "Password", "MY_PASSWORD" ),
))));
var_dump( $client->__getLastRequest() );
var_dump( $client->__getLastResponse() );
print_r( $result );
但是得到错误:
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);
现在我得到错误:
[FaultDescription] => Unable to identify service
[FaultReason] => wsa:To is missing and the given URL /services could not be mapped to an existing service
最佳答案
服务器使用 WS-Addressing(由 FaultReason 证明 - 关键字是 wsa:To
),常规 PHP SoapClient 扩展不支持它。
我还没有使用过 WS-Addressing,但我最近正在分析一个 API,用于我们将来要开展的需要它的项目。
请注意this project或 this other project这可能很有用(搜索更多 PHP WS-Addressing
很容易)。同样,我只做过研究,没有任何实践经验来帮助您编写实际代码:)
关于php - 如何使用 SoapClient 将参数传递给函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33167125/
以下所有内容都在 Amazon EC2 中运行 几个月来我一直在使用 ExactTarget 的 API 发送电子邮件,但它在我的 QA 环境中停止工作了。以下所有代码在我的生产环境中都能正常工作。他
我需要将 PHP 的 SoapClient 与 myfile-ca.crt 一起使用。我如何告诉 SoapClient 构造函数使用客户端证书(crt 文件)? 我熟悉 php SoapClient,
我以这种方式向 WSDL 服务器发送请求: $soap = new SoapClient('WSDL_URI'); $soap->SomeFunction(array('Param1' => 123,
我正在使用带有 WSDL 的 PHP Soap 客户端来发送 SOAP 请求。 这就是我初始化 SoapClient 的方式: $options = [ "trace" => 1,
我正在拔头发。我尝试了很多不同的方法,但没有任何效果: 'localhost', 'proxy_port' => '8888' )); try { $test = new stdCl
这个问题在这里已经有了答案: Does this SOAP Fault mean what I think it means? (3 个答案) 关闭 8 年前。 除了这条错误信息,这里没什么可写的了
我正在尝试从运行该服务的同一台服务器上调用 Soap 客户端以进行测试。我的 WSDL 在:http://www.installittoday.com/api/server.php?wsdl我正在尝试
这个问题在这里已经有了答案: Does this SOAP Fault mean what I think it means? (3 个答案) 关闭 8 年前。 除了这条错误信息,这里没什么可写的了
我正在尝试从运行该服务的同一台服务器上调用 Soap 客户端以进行测试。我的 WSDL 在:http://www.installittoday.com/api/server.php?wsdl我正在尝试
我们需要连接的其中一个 WS 有 PHP 示例代码。他们为我们签署了 CSR ...所以我们现在有用于身份验证的私钥和证书。 他们建议将私钥和签名证书放入一个 .pem 文件,并在 PHP 中使用如下
我在 PhP 中有一个工作的soaprequest,我正在尝试创建一个需要相同调用的java程序,但是我真的很难找到在java中创建以下php代码的方法,我找到了许多网站解释java中的soap请求,
我创建新的 SoapClient $this->soap = new \SoapClient($this->wdls // WDLS with corect host , [ 'excepti
我有一个 Web 服务函数,它向 PHP 客户端返回一组项目。根据项目的数量,PHP 返回类型不同。如果函数返回一项,则 PHP 类型为 stdClass 如果函数返回多项,则 PHP 类型为 arr
我有一个 WSDL,它有一个需要属性的元素: Claim Element 就生成的 xml 而言,它应该如下所示:
我正在使用 SOAP 集成支付网关。当我使用 Wamp 调用服务功能时,它运行良好。但是在我的实时服务器上它给出了以下错误 - Class 'SoapClient' not found 我使用的代码是
我找到了许多关于 SoapClient 希望您如何在请求中设置属性的解释,但我就是找不到从响应中读取属性的方法。 例如,我的 SoapClient 响应中包含以下元素: ... JOWtest
当我发送以下请求时,出现“版本错误”异常。 上面的请求被转换成zend代码 $client = new zend_soap_client(null,
我是 web 服务的新手,我正在尝试使用 soapClient() 调用 web 服务,它生成的请求 XML 不是预期的格式 下面是请求XML的预期格式 MD
另一个 SOAP 问题 - 我有一个大的多维数组,当使用 print_r 时回显很好(例如,您可以看到所有数据)。当我使用 时出现问题 SOAPClient->__soapCall('Function
我最近从 PHP5.4 升级到 PHP7。天哪,这是一个变化,但这不是重点。 升级后我遇到了 SoapService 的问题。 这是我的 SoapRequest 在 PHP5.4 上的样子:
我是一名优秀的程序员,十分优秀!