php 一个SOAP Client的简单测试(带测试实例)(2)
index.php ?phpheader('Content-type:text/html;charset=utf-8');require_once 'city.php';@error_reporting(0);if($_POST['submit'] === 'OK'){ $client = new SoapClient('http://www.webxml.com.cn/WebServices/W
index.php
<?php header('Content-type:text/html;charset=utf-8'); require_once 'city.php'; @error_reporting(0); if($_POST['submit'] === 'OK') { $client = new SoapClient('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'); $code = $_POST['city']; //$code = '深圳'; $para = array('theCityName'=>$code); $res = $client->__Call('getWeatherbyCityName',array('paramters'=>$para))->getWeatherbyCityNameResult->string; echo "<pre>"; echo "城市:".$res[1]; echo "<br/>气温:".$res[5]; echo "<br/>天气:".$res[6]; echo "<br/>风力:".$res[7]; echo "</pre>"; //$qq = $_POST['qqnum']; $qq = '260558820'; if(!empty($qq)) { if(preg_match('/^\d+$/',$qq)) { $client = new SoapClient('http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl',array('trace'=>1)); $para = array('qqCode'=>$qq); $res = $client->__Call('qqCheckOnline',array('paramters'=>$para))->qqCheckOnlineResult; echo $qq.' 目前'.($res=='Y'?'在线':'离线'); } else { echo '<em>错误的qq号码</em>'; } } } ?> <form method="post"> 天气预报查询: <select name="city"> <?php foreach($Citys as $k=>$v) { echo "<option value=\"$k\">$v</option>"; } ?> </select> <br /> QQ在线查询:<input type="text" name="qqnum" /> <input type="submit" value="OK" name="submit" /> </form>
收藏文章
热评话题
- Android定时器实现的几种方式整理及removeCallbacks失效问题解决_Android开发_龙盟编程网
- 在linux中导入sql文件的方法分享(使用命令行转移mysql数据库)_MySQL 技术_龙盟编程网
- 如何应用PHP函数imagettftext处理图片_php编程_个人技术分享
- 在ASP.Net中应用Javascript_Javascript编程_龙盟编程网
- 查询反向链接中link和domain的区别_SEO优化_龙盟编程网
- sql 查询本年、本月、本日记录的语句,附SQL日期函数_Sql Server开发_龙盟编程网
- 如何解决C语言,函数名与宏冲突_C/C++开发_龙盟编程网
精彩图集
精彩文章