2

我正在使用带有 WSDL 文档的 PHP Soap 客户端。客户端是这样创建的:

$client = new SoapClient('http://eklima.met.no/metdata/MetDataService?WSDL');

现在我想调用函数'getCountyTypes',它接受参数'language'和'countiesId'。

$args = array(
    'language'=>'no', 
    'countiesId'=>'2'
);

直接使用函数 __soapCall 按预期工作:

$res = $client->__soapCall('getCountyTypes', $args);

尝试使用魔术函数不起作用:

$res = $client->getCountyTypes($args);

我收到以下错误:

PHP Notice:  Array to string conversion in /Users/jorgen/soaptest.php on line 60
PHP Fatal error:  Uncaught SoapFault exception: [SOAP-ENV:Client] No mapping found for ':countiesId' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'. [java.lang.IllegalArgumentException] in /Users/jorgen/soaptest.php:60
Stack trace:
#0 /Users/jorgen/soaptest.php(60): SoapClient->__call('getCountyTypes', Array)
#1 /Users/jorgen/soaptest.php(60): MySoapClient->getCountyTypes(Array)
#2 {main}
  thrown in /Users/jorgen/soaptest.php on line 60

我需要一些关于如何使用带有魔法功能的肥皂客户端的说明。

编辑:添加了 var_dump($client->__getFunctions()); 的输出

array(14) {
  [0]=>
  string(185) "no_met_metdata_Metdata getMetData(string $timeserietypeID, string $format, string $from, string $to, string $stations, string $elements, string $hours, string $months, string $username)"
  [1]=>
  string(106) "ArrayOfno_met_metdata_TimeSerieTypes getTimeserieTypesProperties(string $language, string $timeserieTypes)"
  [2]=>
  string(99) "ArrayOfno_met_metdata_ElementProperties getElementsProperties(string $language, string $elem_codes)"
  [3]=>
  string(93) "ArrayOfno_met_metdata_ElementProperties getElementsFromTimeserieType(string $timeserietypeID)"
  [4]=>
  string(111) "ArrayOfno_met_metdata_ElementProperties getElementsFromTimeserieTypeStation(string $timeserietypeID, int $stnr)"
  [5]=>
  string(97) "ArrayOfno_met_metdata_StationProperties getStationsProperties(string $stations, string $username)"
  [6]=>
  string(111) "ArrayOfno_met_metdata_StationProperties getStationsFromTimeserieType(string $timeserietypeID, string $username)"
  [7]=>
  string(140) "ArrayOfno_met_metdata_StationProperties getStationsFromTimeserieTypeElemCodes(string $timeserietypeID, string $elem_codes, string $username)"
  [8]=>
  string(162) "ArrayOfno_met_metdata_StationProperties getStationsFromTimeserieTypeStationsElemCode(string $timeserietype, string $stations, string $elem_code, string $username)"
  [9]=>
  string(22) "string getDateFormat()"
  [10]=>
  string(89) "ArrayOfno_met_metdata_FlagProperties getFlagProperties(string $language, string $flagsId)"
  [11]=>
  string(110) "ArrayOfno_met_metdata_PrecipitationTypes getPrecipitationTypes(string $language, string $precipitationTypesId)"
  [12]=>
  string(33) "ArrayOfString getValidLanguages()"
  [13]=>
  string(86) "ArrayOfno_met_metdata_CountyTypes getCountyTypes(string $language, string $countiesId)"
}
4

2 回答 2

0

我有同样的问题。我认为我必须执行以下操作:

$args = array(
    'language'=>'no', 
    'countiesId'=>'2' );

$res = $client->getCountyTypes($args);

但实际上我必须这样做:

$res = $client->getCountyTypes("no","2");
于 2013-05-23T08:29:13.887 回答
0

正如aravind.udayashankara所指出的,正确的解决方案是使用

$res = $client->__soapCall('getCountyTypes', $args);
于 2013-02-11T15:59:29.230 回答