webservices应用----查询航班

程序结果


开启php.ini
extension=php_soap.dll

webservices接口

http://ws.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl

webservices函数使用

http://ws.webxml.com.cn/webservices/DomesticAirline.asmx

PHP代码

<?php

header("Content-type: text/html; charset=utf-8");

//查询城市列表
$client = new SoapClient('http://ws.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl');
$result = $client  -> getDomesticCity() -> getDomesticCityResult -> any; 
$city = new SimpleXMLElement($result);
$address = $city -> Airline1 -> Address;

//形成表单
echo "<form id ='form' name = 'city' method = 'post' action = ''>";
echo "开始城市:<select name='startCity'>";
foreach ($address as $city){
    echo "<option value={$city -> cnCityName}>{$city -> cnCityName}</option>";
}
echo "</select>";
echo " ";
echo "到达城市:<select name='lastCity'>";
foreach ($address as $city){
    echo "<option value={$city -> cnCityName}>{$city -> cnCityName}</option>";
}
echo "</select>"; 
echo " ";
echo "时间:<input type='text' name='theDate' value='" . date("Y-m-d") . "'/>";
echo "<input type='submit' />";
echo "</form>";

if($_POST){
    //获取表单数据
    $startCity = $_POST['startCity'];
    $lastCity = $_POST['lastCity'];
    $theDate = $_POST['theDate'];
    $param = array(
      'startCity' => $startCity,
      'lastCity' => $lastCity,
      'theDate' => $theDate,  
      'userID' => ""
    );
    //查询
    $result = $client -> getDomesticAirlinesTime($param) -> getDomesticAirlinesTimeResult ->any;
    echo "<hr />";
    $airline = new SimpleXMLElement($result) ;
    $airline_arr = $airline -> Airlines -> AirlinesTime;
//    var_dump($airline_arr);
    if("没有航班" == $airline_arr[0] -> Company){
        echo "没有航班。。。。";
    }else{
        echo "<table width='1000' border='1'>";
        echo "<tr><th>航空公司</th><th>航班</th><th>出发机场</th><th>到达机场</th><th>起飞时间</th><th>到达时间</th><th>机型</th><th>停靠站</th><th>飞行日期</th></tr>";
        foreach ($airline_arr as $air){
            echo "<tr><td>{$air -> Company}</td><td>{$air -> AirlineCode}</td><td>{$air -> StartDrome}</td><td>{$air -> ArriveDrome}</td>"
            . "<td>{$air -> StartTime}</td><td>{$air -> ArriveTime}</td><td>{$air -> Mode}</td><td>{$air -> AirlineStop}</td><td>{$air -> Week}</td></tr>";
        }
        echo"</table>";
    }
    
}




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值