當我運行以下腳本時,我得到一個「class stdClass的對象無法轉換爲SOAP請求的字符串」錯誤$client->LatLonListZipCode($args)
行和I無法弄清楚爲什麼。有任何想法嗎?class stdClass的對象無法轉換爲SOAP請求的字符串
<?php
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
),
'http' => array(
'timeout' => 5 //seconds
)
);
//create stream context
$stream_context = stream_context_create($contextOptions);
//create client instance (over HTTPS)
$client = new SoapClient('http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl', array(
'cache_wsdl' => WSDL_CACHE_NONE,
'exceptions' => 1,
'trace' => 1,
'stream_context' => $stream_context,
'soap_version'=> SOAP_1_2,
'connection_timeout' => 5 //seconds
));//SoapClient
$args = new stdClass();
$args->zipCodeList = '10001';
$z = $client->LatLonListZipCode($args);
'LatLonListZipCode'在傳遞'stdClass'時需要一個字符串作爲參數。除非您將分享關於期望的'LatLonListZipCode'參數列表的知識,否則沒有什麼可添加的。 'SoapClient' [操作字符串實例](http://php.net/manual/en/class.soapclient.php)。 – mudasobwa 2015-04-08 14:34:20
@mudasobwa - 我並不假裝是一位SOAP專家,但在我看來,WSDL期望將字符串作爲名爲zipCodeList的參數傳遞給它。如果我做'$ client-> LatLonListZipCode('10001')'它怎麼知道參數名是什麼?無論如何,我嘗試了它,並得到了一個'PHP致命錯誤:未捕獲SoapFault異常:[SOAP-ENV:客戶端]操作''未在此服務的WSDL中定義錯誤 – neubert 2015-04-08 14:37:49
您是否願意嘗試' $ client - > __ soapCall('LatLonListZipCode',array('zipCodeList'=> array('10001')))'['__soapCall'](http://php.net/manual/de/soapclient.soapcall.php)總是爲我工作。 – mudasobwa 2015-04-08 15:04:44