我使用PHP SOAP客戶端與WSDL document.The客戶端創建這樣的:獲得神奇的功能在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
我需要一些可怕的東西關於如何使用帶有魔術功能的soap客戶端的說明。
編輯:增加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)"
}
你可以做$客戶端=新SoapClient的($ wsdl_url); var_dump($ client - > __ getFunctions());並在這裏粘貼Vardumped數據,以便我們可以看到實際存在的問題 –
我將輸出添加到問題中。感謝您的關注。 – jorgenfb
實際上你期望使用魔法方法__call來執行這個操作,因爲這個$ res = $ client-> getCountyTypes($ args);在任何時候都不起作用,因爲正確的做法是不同的 –