web服务用的是SOAP(简单对象访问协议):是web服务的通信协议,用来定义返回消息的XML格式的规范,
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>无标题文档</title> 6 </head> 7 8 <body> 9 <?php10 $client=new SoapClient(‘http://ws.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl‘);11 $city=$client->getDomesticCity()->getDomesticCityResult->any;12 $simple=new SimpleXMLElement($city);13 $addr_array=$simple->Airline1->Address;14 //echo ‘<pre>‘;15 //var_dump($addr_array);16 ?>17 <form id="form1" name="form1" method="post" action="">18 出发城市:19 <select name="startCity" id="startCity">20 <?php21 foreach($addr_array as $row):22 ?>23 <option value="<?php echo $row->cnCityName?>"><?php echo $row->cnCityName?></option>24 <?php25 endforeach;26 ?>27 </select>28 到达城市:29 <select name="lastCity" id="lastCity">30 <?php31 foreach($addr_array as $row):32 ?>33 <option value="<?php echo $row->cnCityName?>"><?php echo $row->cnCityName?></option>34 <?php35 endforeach;36 ?>37 </select>38 时间:<input type="text" name="theDate" value="<?php echo date(‘Y-m-d‘)?>" />39 <input type="submit" name="button" id="button" value="提交" />40 </form>41 <?php42 if(!empty($_POST)){43 $startCity=$_POST[‘startCity‘];44 $lastCity=$_POST[‘lastCity‘];45 $theDate=$_POST[‘theDate‘];46 $param=array(47 ‘startCity‘=>$startCity,48 ‘lastCity‘=>$lastCity,49 ‘theDate‘=>$theDate,50 ‘userID‘=>‘‘51 );52 $airline_str=$client->getDomesticAirlinesTime($param)->getDomesticAirlinesTimeResult->any;53 //var_dump($rs);54 $simple=new SimpleXMLElement($airline_str);55 $airline_array=$simple->Airlines->AirlinesTime;56 ?>57 <table width="780" border="1" bordercolor="#000000" align="center">58 <tr>59 <th>航空公司</th>60 <th>航班</th>61 <th>出发机场</th>62 <th>到达机场</th>63 <th>起飞时间</th>64 <th>到达时间</th>65 <th>机型</th>66 <th>停靠站</th>67 <th>飞行日期</th>68 </tr>69 <?php70 foreach($airline_array as $airline):71 ?>72 <tr>73 <td><?php echo $airline->Company?></td>74 <td><?php echo $airline->AirlineCode?></td>75 <td><?php echo $airline->StartDrome?></td>76 <td><?php echo $airline->ArriveDrome?></td>77 <td><?php echo $airline->StartTime?></td>78 <td><?php echo $airline->ArriveTime?></td>79 <td><?php echo $airline->Mode?></td>80 <td><?php echo $airline->AirlineStop?></td>81 <td><?php echo $airline->Week?></td>82 </tr>83 <?php84 endforeach;85 ?>86 </table>87 <?php88 }89 ?>90 91 </body>92 </html>
View Code