简单的soap调用返回致命错误,函数不是有效的方法

时间:2017-02-26 14:09:34

标签: php soap

我似乎无法围绕SOAP调用。我已经花了好几个小时从WSDL文件中获取一些简单的信息

$client = new SoapClient('https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl');
$params = array(2017,1,'en');
$functions = $client->__soapCall(getMonthlyAverageExchangeRatesResponse, array(getMonthlyAverageExchangeRates, $params));
var_dump($functions);

但这只返回“未捕获的SoapFault异常:[客户端]函数(”getMonthlyAverageExchangeRatesResponse“)不是此服务的有效方法......”

执行函数的var转储

$functions = $client->__getFunctions();
var_dump($functions);

告诉我

array(9) { [0]=> string(104) "getInterestAndExchangeNamesResponse getInterestAndExchangeNames(getInterestAndExchangeNames $parameters)" [1]=> string(113) "getMonthlyAverageExchangeRatesResponse getMonthlyAverageExchangeRates(getMonthlyAverageExchangeRates $parameters)" [2]=> string(122) "getLatestInterestAndExchangeRatesResponse getLatestInterestAndExchangeRates(getLatestInterestAndExchangeRates $parameters)" [3]=> string(119) "getInterestAndExchangeGroupNamesResponse getInterestAndExchangeGroupNames(getInterestAndExchangeGroupNames $parameters)" [4]=> string(62) "getCrossRatesResponse getCrossRates(getCrossRates $parameters)" [5]=> string(71) "getAllCrossNamesResponse getAllCrossNames(getAllCrossNames $parameters)" [6]=> string(68) "getCalendarDaysResponse getCalendarDays(getCalendarDays $parameters)" [7]=> string(110) "getAnnualAverageExchangeRatesResponse getAnnualAverageExchangeRates(getAnnualAverageExchangeRates $parameters)" [8]=> string(104) "getInterestAndExchangeRatesResponse getInterestAndExchangeRates(getInterestAndExchangeRates $parameters)" }

我要做的就是获取“getMonthlyAverageExchangeRates(getMonthlyAverageExchangeRates $ parameters)”。 我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

好的,接受了一些试验和错误,但我终于得到了语法。对于其他任何正在努力处理不需要任何身份验证的类似简单SOAP请求的人 -

$client = new SoapClient('https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl');
$parameters = array(
'year' => 2017,
'month' => 1,
'languageid' => 'en'    
);
$functions =  $client->getMonthlyAverageExchangeRates($parameters);

如果你想看看给出的语法,以了解如何在PHP中使用它

http://www.riksbank.se/sv/Rantor-och-valutakurser/Web-Services/