xml的Web服务
发布时间:2020-12-16 08:13:56 所属栏目:百科 来源:网络整理
导读:Web服务用的是SOAP(简单对象访问协议):是web服务的通信协议,用来定义返回信息的xml格式的规范 技术 后缀 Asp .asp php .php .net(跨语言) .aspx java .jsp Wsdl:web服务描述语言,包括一系列web服务的定义。 注意:PHP默认不支持soap协议的,要在php.i
Web服务用的是SOAP(简单对象访问协议):是web服务的通信协议,用来定义返回信息的xml格式的规范
Wsdl:web服务描述语言,包括一系列web服务的定义。 注意:PHP默认不支持soap协议的,要在php.ini中开启soap协议
重启服务器
php利用xml调用国际航班
<?php echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; $client = new SoapClient('http://ws.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl'); $city = $client->getDomesticCity()->getDomesticCityResult->any; $simple = new SimpleXMLElement($city); $addr_array = $simple->Airline1->Address; ?> <form id="form1" name="form1" method="post" action=""> 出发城市: <select name="startCity" id="startCity"> <?php foreach($addr_array as $row) : ?> <option><?php echo $row->cnCityName; ?></option> <?php endforeach; ?> </select> 到达城市: <select name="lastCity" id="lastCity"> <?php foreach($addr_array as $row) : ?> <option><?php echo $row->cnCityName; ?></option> <?php endforeach; ?> </select> 时间:<input type="text" name="theDate" value="<?php echo date('Y-m-d'); ?>" /> <input type="submit" name="button" id="button" value="提交" /> </form> <?php if(!empty($_POST)){ $startCity = $_POST['startCity']; $lastCity = $_POST['lastCity']; $theDate = $_POST['theDate']; $param = array( 'startCity'=>$startCity,'lastCity'=>$lastCity,'theDate'=>$theDate,'userId'=>'' ); $airline_str = $client->getDomesticAirlinesTime($param)->getDomesticAirlinesTimeResult->any; $simple = new SimpleXMLElement($airline_str); echo '<pre>'; $airline_array = $simple->Airlines->AirlinesTime; ?> <table width="780" border="1" bordercolor="#000000" align="center"> <tr> <th>航空公司</th> <th>航班</th> <th>出发机场</th> <th>到达机场</th> <th>起飞时间</th> <th>到达时间</th> <th>机型</th> <th>停靠站</th> <th>分型日期</th> </tr> <?php foreach($airline_array as $airline) : ?> <tr> <th><?php echo $airline->Company; ?></th> <th><?php echo $airline->AirlineCode; ?></th> <th><?php echo $airline->StartDrome; ?></th> <th><?php echo $airline->ArriveDrome; ?></th> <th><?php echo $airline->StartTime; ?></th> <th><?php echo $airline->ArriveTime; ?></th> <th><?php echo $airline->Mode; ?></th> <th><?php echo $airline->AirlineStop; ?></th> <th><?php echo $airline->Week; ?></th> </tr> <?php endforeach; ?> </table> <?php } ?> 执行效果图:
php利用xml调用本地ip访问
<?php echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; $client = new SoapClient('http://ws.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl'); $Ip = $client->getGeoIPContext()->getGeoIPContextResult->string; ?> <table width="780" border="1" bordercolor="#000000" align="center"> <tr> <th>网址</th> </tr> <?php foreach($Ip as $ip) : ?> <tr> <th><?php echo $ip; ?></th> </tr> <?php endforeach; ?> </table> <?php 执行效果图:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 保存在主机上时,文件不会在vagrant中更新
- Flash Builder 4.6 插件安装问题
- JSONP存在的JSON Hijacking漏洞以及与csrf/xss漏洞的关系
- ruby-on-rails – 如何期望在Rails中使用某些参数将消息发送
- do{}while(0)出现在cocos2dx
- 在某些AJAX调用中出现“net :: ERR_BLOCKED_BY_CLIENT”错误
- 编程语言 10 月排行榜:Swift 持续下降,Java\/C\/
- ruby-on-rails – 每次推送到heroku,图像都没有显示,回形针
- 基于Ruby的类似位置合并数组的哈希值
- C#简单实现文件上传功能