【问题标题】:Cannot get response from PHP Soapclient无法从 PHP Soapclient 获得响应
【发布时间】:2019-08-26 05:24:52
【问题描述】:

我正在尝试从发送 PHP SoapClient 请求中获取响应。我的理解是,在 Soap 中,该类存在于 Soap-server 上,并被指定并作为 Soapclient 的参数获取,并指出 wsdl 文件。

我正在使用以下链接参考:

网络服务:

PHP 肥皂客户端:

How to make a PHP SOAP call using the SoapClient class


我的代码:

<? php
$client = new SoapClient("https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl");

$params = array (
    "year" => 2010,
    "month" => 4
);

$response = $client->__soapCall('getAnnualAverageExchangeRates()', array($params));

var_dump($response);

错误信息:

PHP Fatal error:  Uncaught Error: Class 'SoapClient' not found in /[path/Xxx.php:4
Stack trace:
#0 {main}
  thrown in /path/Xxx.php on line 4
    var_dump($response)

【问题讨论】:

  • 1.该函数需要三个参数,您只提供两个。 2.在__soapCall中省略函数名中的括号
  • 主要问题是我没有安装soap。我确实遇到了另一个错误,但会提出另一个问题以便更好地澄清。
  • 它现在正在工作。我省略了函数名中的括号,并在 params 数组中添加了“languageid”。

标签: php soap soap-client soapserver


【解决方案1】:

首先您需要从php.ini 启用Soap 扩展。重启阿帕奇。然后检查phpinfo() 以确保加载了扩展。

$option = array('trace' => 1, 'keep_alive' => true,'connection_timeout' => 60);// add options here
$client = new SoapClient("https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl", $option);

$params = array (
    "year" => 2010,
    "month" => 4,
    "languageid" => 1 //language id may differ.
);

// you can directly call function from  wsdl.
$response = $client->getAnnualAverageExchangeRates(array($params));

var_dump($response);

【讨论】:

    猜你喜欢
    • 2020-08-25
    • 2021-07-18
    • 2018-02-20
    • 2020-12-11
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多