我想使用SOAP/wsdl连接到webservice,但我经常得到错误。我是php中的soap-api中的新成员。我有一个API文件的详细信息,它显示:PHP肥皂调用错误
public WSGetCalendarFareResponse GetCalendarFare(WSGetCalendarFareRequest calanderFareRequest)
我相应地做了我的代码,但仍然发现错误/异常。请查看我的PHP代码如下:
$wsdl = "http://api.abc.com/xyz/service.asmx?wsdl"; // This is a test Web Service URL
$h = array();
$opta["GetCalendarFare"]["request"]= array(
"Origin"=>"DEL",
"Destination"=>"IXR",
"DepartureDate"=>"2015-05-01T00:00:00",
"ReturnDate"=>"2015-05-01T00:00:00",
"Type"=>"OneWay",
"CabinClass"=>"All",
"PreferredCarrier"=>"",
"AdultCount"=>1,
"ChildCount"=>1,
"InfantCount"=>"0",
"SeniorCount"=>"0",
"PromotionalPlanType"=>"Normal",
"IsDirectFlight"=>false
);
$client_header = new SoapHeader('http://192.168.0.0/TEST/BookingAPI','AuthenticationData',$hparams,false);
$cliente = new SoapClient($wsdl, array('trace' => 0));
$cliente->__setSoapHeaders(array($client_header));
try{
$h= (array)$cliente->__call('GetCalendarFare',$opta);
}catch(Exception $e)
{
echo '<pre>';
var_dump($e);
}
当我执行我的代码,它返回以下错误:
"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at BookingAPI.WSCalendarFareInput(WSGetCalendarFareRequest calanderFareRequest) in c:\inetpub\wwwroot\api.tektravel.com\TboApi_V7\App_Code\Service.cs:line 4544
at BookingAPI.GetCalendarFare(WSGetCalendarFareRequest calanderFareRequest) in c:\inetpub\wwwroot\api.tektravel.com\TboApi_V7\App_Code\Service.cs:line 4360
任何人都可以请建议,哪里存在问题?它尝试多次尝试&,但无法获得错误点。
三江源的Seb。你说得对,我在请求中犯了错误。我必须设置请求值如下:$ opta [“GetCalendarFare”] [“calanderFareRequest”] = array();谢谢你的评论。 – 2015-02-23 10:05:30
如果你可以将我的答案标记为正确或至少是赞成这一提示,那就太好了。 ;) – Seb 2015-02-23 11:00:12