// 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调用函数正在运行......我需要将选项数组传递给一个参数....
LINE 269
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
答案 0 :(得分:3)
这可能已经解决了,但我也有这个问题,我想我应该在最终找到解决方案时发帖。 (解决方案不是nusoap,它会抛出相同的错误。)
错误似乎只来自soapCall调用生成,它确实是导致它的Web服务。当您运行__soapCall时,它首先询问服务器参数应具有哪些数据类型,然后尝试遵守。因此,如果您在服务需要字符串时尝试提供数组,则会在生成请求时将数组转换为字符串转换。
答案 1 :(得分:1)
我认为您应该查看手册soapcall work:
的方式$params = 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'=>'House', // changed to string instead of array
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'' );
我简化了数组,您应该对其进行测试,看看这是否是您正在寻找的结果。
还要查看排序错误,例如php.net
中显示的示例