关闭

webservices应用----查询航班

192人阅读 评论(0) 收藏 举报
分类:

程序结果


开启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
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:22168次
    • 积分:460
    • 等级:
    • 排名:千里之外
    • 原创:23篇
    • 转载:3篇
    • 译文:9篇
    • 评论:2条
    最新评论