【发布时间】:2011-05-22 08:09:32
【问题描述】:
// Set username and password
$ih_soap_user= $this->config->item('interUser');
$ih_soap_pass=$this->config->item('interPass');
//echo $ih_soap_user.':P:'.$ih_soap_pass;
// Set soap namespace
$ih_soap_ns = 'http://www.interhome.com/webservice';
// Create new instance of SoapClient with the interhome web service URL
$client = new
SoapClient($this->config->item('interSoap'),array('trace'=>'1'));
// Create new soap header and set username and password
$header = new SoapHeader($ih_soap_ns,
'ServiceAuthHeader',
array('Username' => $ih_soap_user,'Password' =>
$ih_soap_pass),
true
);
// Prepare p// Prepare parameters
$params = array('inputValue' =>array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>array('House'=>'House'),
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'',
) );
try{
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
大家好..任何想法为什么当我传递任何非空数组时调用此调用,例如,正如我为“HouseApartmentType”所做的那样,返回此错误
遇到 PHP 错误严重性:通知
消息: 数组到字符串的转换
文件名: controllers/houses.php
行 数量:269
当它只是空数组或字符串时,soap 调用函数正在工作......我需要将一组选项传递给一个参数......
第 269 行是
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
【问题讨论】:
-
如果你的api只支持字符串,也许你应该序列化数组...
-
@Ibu 这不是我从 API 服务器收到的错误...我在调用生成期间收到此错误
-
错误说,数组到字符串的转换,所以错误与被转换的数组有关,你能显示代码的第269行吗
-
我已经编辑了帖子并显示了@Ibu,这是拨打电话的那一行
标签: php soap-client