Home  >  Article  >  Backend Development  >  A simple test of SOAP Client (with test example)

A simple test of SOAP Client (with test example)

WBOY
WBOYOriginal
2016-07-25 09:08:551733browse
Collect and organize the codes yourself to simply implement weather and QQ online queries. For reference only, welcome to submit.
  1. /*Generate at Sun, 04 Jan 2009 13:46:27 +0000
  2. Don't Modify Me!
  3. Cache Name Citys
  4. key:a5819c80f61198eabf3d3ffceec595de
  5. */
  6. $Citys =array (
  7. ' ' Macao',
  8. 50953 => 'Harbin',
  9. 50745 => 'Qiqihar',
  10. 54094 => 'Mudanjiang',
  11. 50842 => 'Daqing',
  12. 50774 => 'Yichun',
  13. 50884 => 'Shuangyashan',
  14. 50775 => 'Hegang',
  15. 50978 => 'Jixi',
  16. 50873 => 'Jiamusi',
  17. 50971 => 'Qitaihe',
  18. 50468 = > 'Heihe',
  19. 50853 => 'Suihua',
  20. 50442 => 'Daxinganling',
  21. 54161 => 'Changchun',
  22. 54172 => 'Jilin',
  23. 54371 => 'White Mountain' ,
  24. 50936 => 'Baicheng',
  25. 54157 => 'Siping',
  26. 50946 => 'Songyuan',
  27. 54260 => 'Liaoyuan',
  28. 50945 => 'Da'an',
  29. 54363 => 'Tonghua',
  30. 54342 => 'Shenyang',
  31. 54662 => 'Dalian',
  32. 54453 => 'Huludao',
  33. 54660 => 'Lushun',
  34. 54346 => 'Benxi' ,
  35. 54353 => 'Fushun',
  36. 54249 => 'Tieling',
  37. 54347 => 'Liaoyang',
  38. 54471 => 'Yingkou',
  39. 54237 => '阜新',
  40. 54324 => 'Chaoyang',
  41. 54337 => 'Jinzhou',
  42. 54497 => 'Dandong',
  43. 54339 => 'Anshan',
  44. 53463 => 'Hohhot',
  45. 54102 => 'Xilinhot',
  46. 53446 => 'Baotou',
  47. 54218 => 'Chifeng',
  48. 50527 => 'Hailaer',
  49. 53512 => 'Wuhai',
  50. 53543 => 'Ordos',
  51. 54135 => 'Tongliao',
  52. 53698 => 'Shijiazhuang',
  53. 54534 => 'Tangshan',
  54. 54401 => 'Zhangjiakou',
  55. 54515 => 'Langfang',
  56. 53798 => 'Xingtai',
  57. 53892 => 'Handan',
  58. 54616 => 'Cangzhou',
  59. 54702 => 'Hengshui',
  60. 54423 => 'Chengde',
  61. 54602 => 'Baoding',
  62. 54449 => 'Qinhuangdao',
  63. 57083 => 'Zhengzhou',
  64. 57091 => 'Kaifeng',
  65. 57073 => 'Luoyang',
  66. 57171 => 'Pingdingshan',
  67. 53982 => 'Jiaozuo',
  68. ' 'Luohe',
  69. 57051 => 'Sanmenxia',
  70. 57178 => 'Nanyang',
  71. 58005 => 'Shangqiu',
  72. 57297 => 'Xinyang',
  73. 57195 => 'Zhoukou',
  74. 57290 => 'Zhumadian',
  75. 54823 => 'Jinan',
  76. 54857 => 'Qingdao',
  77. 54830 => 'Zibo',
  78. 54774 => 'Weihai',
  79. 54918 => 'Quyu ',
  80. 54938 => 'Linyi',
  81. 54765 => 'Yantai',
  82. 58024 => 'Zaozhuang',
  83. 54806 => 'Liaocheng',
  84. 54915 => 'Jining',
  85. 54906 = > 'Heze',
  86. 54827 => 'Tai'an',
  87. 54945 => 'Rizhao',
  88. 54736 => 'Dongying',
  89. 54714 => 'Dezhou',
  90. 54734 => 'Binzhou' ,
  91. 54828 => 'Laiwu',
  92. 54843 => 'Weifang',
  93. 53772 => 'Taiyuan',
  94. 53782 => 'Yangquan',
  95. 53976 => 'Jincheng',
  96. 53778 => 'Jinzhong',
  97. 53868 => 'Linfen',
  98. 53959 => 'Yuncheng',
  99. 53882 => 'Changzhi',
  100. 53578 => 'Shuozhou',
  101. 53674 => 'Xinzhou ',
  102. 53487 => 'Datong',
  103. 58238 => 'Nanjing',
  104. 58357 => 'Suzhou',
  105. 58356 => 'Kunshan',
  106. 58259 => 'Nantong',
  107. 58377 = > 'Taicang',
  108. 58349 => 'Wuxian',
  109. 58027 => 'Xuzhou',
  110. 58346 => 'Yixing',
  111. 58248 => 'Zhenjiang',
  112. 58145 => 'Huai'an' ,
  113. 58352 => 'Changshu',
  114. 58151 => 'Yancheng',
  115. 58246 => 'Taizhou',
  116. 58354 => 'Wuxi',
  117. 58044 => 'Lianyungang',
  118. 58245 => 'Yangzhou',
  119. 58343 => 'Changzhou',
  120. 58131 => 'Suqian',
  121. 58321 => 'Hefei',
  122. 58326 => 'Chaohu',
  123. 58221 => '茌埠',
  124. 58424 => 'Anqing',
  125. 58311 => 'Liu'an',
  126. 58236 => 'Chuzhou',
  127. 58336 => 'Ma'anshan',
  128. 58203 => 'Fuyang',
  129. 58433 => 'Xuancheng',
  130. 58429 => 'Tongling',
  131. 58116 => 'Huaibei',
  132. 58334 => 'Wuhu',
  133. 58122 => 'Suzhou',
  134. 58224 => 'Huainan' ,
  135. 58427 => 'Chizhou',
  136. 57036 => 'Xi'an',
  137. 53955 => 'Hancheng',
  138. 57245 => 'Ankang',
  139. 57127 => 'Hanzhong',
  140. ' Tongchuan',
  141. 53845 => 'Yan'an',
  142. 53614 => 'Yinchuan',
  143. 53817 => 'Guyuan',
  144. 53704 => 'Zhongwei',
  145. 53518 => 'Shizuishan',
  146. 53612 ' Tianshui',
  147. 52679 => 'Wuwei',
  148. 52652 => 'Zhangye',
  149. 50741 => 'Gannan',
  150. 52984 => 'Linxia',
  151. 53915 => 'Pingliang',
  152. 52995 ' 'Huangnan',
  153. 56043 => 'Guoluo',
  154. 56029 => 'Yushu',
  155. 52875 => 'Haidong',
  156. 52856 => 'Hainan',
  157. 57494 => 'Wuhan' ,
  158. 57461 => 'Yichang',
  159. 57498 => 'Huanggang',
  160. 57447 ​​=> 'Enshi',
  161. 57476 => 'Jingzhou',
  162. 57362 => 'Shennongjia',
  163. 57256 => 'Shiyan',
  164. 57590 => 'Xianning',
  165. 57278 => 'Xiangfan',
  166. 57482 => 'Xiaogan',
  167. 57381 => 'Suizhou',
  168. 58407 => 'Huangshi',
  169. 57377 => 'Jingmen',
  170. 57496 => 'Ezhou',
  171. 57679 => 'Changsha',
  172. 57766 => 'Shaoyang',
  173. 57662 => 'Changde',
  174. 57972 => 'Chenzhou',
  175. 57649 => 'Jishou',
  176. 57780 => 'Zhuzhou',
  177. 57763 => 'Loudi',
  178. 57773 => 'Xiangtan',
  179. 57674 => 'Yiyang',
  180. ' Zhangjiajie',
  181. 58457 => 'Hangzhou',
  182. 58450 => 'Huzhou',
  183. 58549 => 'Jinhua',
  184. 58563 => 'Ningbo',
  185. 58646 => 'Lishui',
  186. 58453 => 'Shaoxing',
  187. 58633 => 'Quzhou',
  188. 58452 => 'Jiaxing',
  189. 58660 => 'Taizhou',
  190. 58477 => 'Zhoushan',
  191. 58659 => 'Wenzhou ',
  192. 58606 => 'Nanchang',
  193. 57786 => 'Pingxiang',
  194. 58502 => 'Jiujiang',
  195. 58637 => 'Shangrao',
  196. 58617 => 'Fuzhou',
  197. 57799 = > 'Jian',
  198. 58627 => 'Yingtan',
  199. 57793 => 'Yichun',
  200. 57796 => 'Xinyu',
  201. 58527 => 'Jingdezhen',
  202. 57993 => 'Ganzhou' ,
  203. 58847 => 'Fuzhou',
  204. 59134 => 'Xiamen',
  205. 58927 => 'Longyan',
  206. 58834 => 'Nanping',
  207. 58846 => 'Ningde',
  208. 58946 => 'Putian',
  209. 59137 => 'Quanzhou',
  210. 58828 => 'Sanming',
  211. 59126 => 'Zhangzhou',
  212. 57816 => 'Guiyang',
  213. 57806 => 'Anshun',
  214. 57609 => 'Chishui',
  215. 57713 => 'Zunyi',
  216. 57741 => 'Tongren',
  217. 56693 => 'Liupanshui',
  218. 57707 => 'Bijie',
  219. 57825 => 'Kaili',
  220. 57827 => 'Duyun',
  221. 56294 => 'Chengdu',
  222. 57602 => 'Luzhou',
  223. 57504 => 'Neijiang',
  224. 56571 => 'Liangshan' ,
  225. 56171 => 'Aba',
  226. 57313 => 'Bazhong',
  227. 57206 => 'Guangyuan',
  228. 56386 => 'Leshan',
  229. 56196 => 'Mianyang',
  230. 56198 = > 'Deyang',
  231. 56666 => 'Panzhihua',
  232. 56287 => 'Ya'an',
  233. 56492 => 'Yibin',
  234. 56396 => 'Zigong',
  235. 56146 => 'Ganzi Prefecture ',
  236. 57328 => 'Dazhou',
  237. 56298 => 'Ziyang',
  238. 57415 => 'Guang'an',
  239. 57405 => 'Suining',
  240. 56391 => 'Meishan',
  241. 57411 = > 'Nanchong',
  242. 59287 => 'Guangzhou',
  243. 59493 => 'Shenzhen',
  244. 59312 => 'Chaozhou',
  245. 59082 => 'Shaoguan',
  246. 59658 => 'Zhanjiang' ,
  247. 59298 => 'Huizhou',
  248. 59280 => 'Qingyuan',
  249. 59289 => 'Dongguan',
  250. 59473 => 'Jiangmen',
  251. 59659 => 'Maoming',
  252. 59278 => 'Zhaoqing',
  253. 59501 => 'Shantou',
  254. 59293 => 'Heyuan',
  255. 59315 => 'Jieyang',
  256. 59117 => 'Meizhou',
  257. 59485 => 'Zhongshan',
  258. 59269 => 'Deqing',
  259. 59663 => 'Yangjiang',
  260. 59471 => 'Yunfu',
  261. 59488 => 'Zhuhai',
  262. 59316 => 'Shantou',
  263. 59431 => 'Nanning',
  264. 57957 => 'Guilin',
  265. 59051 => 'Yangshuo',
  266. 59046 => 'Liuzhou',
  267. 59265 => 'Wuzhou',
  268. 59453 => 'Yulin',
  269. 59254 => 'Guiping',
  270. 59065 => 'Hezhou',
  271. 59632 => 'Qinzhou',
  272. 59249 => 'Guigang',
  273. 59635 => 'Fangchenggang',
  274. 59211 => 'Baise',
  275. 59644 => 'Beihai',
  276. 59023 => 'Hechi',
  277. 59242 => 'Laibin',
  278. 59425 => 'Chongzuo',
  279. 56778 => 'Kunming',
  280. 56748 => 'Baoshan',
  281. 56768 => 'Chuxiong',
  282. 56844 => 'Dehong',
  283. 56975 => 'Red River',
  284. 56951 => 'Lincang',
  285. 56533 => 'Nujiang' ,
  286. 56783 => 'Qujing',
  287. 56964 => 'Simao',
  288. 56994 => 'Wenshan',
  289. 56875 => 'Yuxi',
  290. 56586 => 'Zhaotong',
  291. 56651 => 'Lijiang',
  292. 56751 => 'Dali',
  293. 59758 => 'Haikou',
  294. 59948 => 'Sanya',
  295. 59845 => 'Dali',
  296. 59757 => 'Qiongshan ',
  297. 59941 => 'Tongshi',
  298. 59856 => 'Wenchang',
  299. 51463 => 'Urumqi',
  300. 51076 => 'Altay',
  301. 51628 => 'Aksu',
  302. 51368 => 'Changji',
  303. 52203 => 'Hami',
  304. 51828 => 'Hotian',
  305. 51709 => 'Kashgar',
  306. 51243 => 'Karamay',
  307. 51356 => 'Shihezi ',
  308. 51133 => 'Tacheng',
  309. 51656 => 'Korla',
  310. 51573 => 'Turpan',
  311. 55591 => 'Lhasa',
  312. 55437 => 'Ali',
  313. 56137 => 'Chamdo',
  314. 55299 => 'Naqu',
  315. 55578 => 'Shigatse',
  316. 55598 => 'Shannan',
  317. 56312 => 'Lingzhi',
  318. 58968 => 'Taipei ',
  319. 59554 => 'KAOHSIUNG',
  320. 17060 => 'ISTANBUL ',
  321. 40754 => 'TEHRAN ',
  322. 41781 => 'KARACHI ',
  323. 42182 => 'NEW DELHI ',
  324. 43466 => 'COLOMBO ',
  325. 47108 => 'SEOUL ',
  326. 47159 => 'BUSAN ',
  327. 47662 => 'TOKYO ',
  328. 48097 => 'Yangon YANGON ',
  329. 48454 => 'BANGKOK ',
  330. 48647 => 'KUALA LUMPUR ',
  331. 48820 => 'HA NOI ',
  332. 96745 => 'JAKARTA ',
  333. 10141 => 'HAMBURG',
  334. 10381 => 'BERLIN',
  335. 10637 => 'FRANKFURT',
  336. 11034 => 'VIENNA',
  337. 16066 => 'MILANO',
  338. 16235 => 'ROMA',
  339. 16701 => 'ATHENS',
  340. 2484 => 'STOCKHOLM',
  341. 27612 => 'MOSKVA',
  342. 3334 => 'MANCHESTER',
  343. 3779 => 'LONDON ',
  344. 6240 => 'AMSTERDAM ',
  345. 6451 => 'BRUSSELES ',
  346. 6660 => 'ZURICH ',
  347. 6700 => 'GENEVE ',
  348. 61291 => 'BAMAKO ',
  349. 63450 => 'ADDIS ABABA ',
  350. 63740 => 'NAIROBI ',
  351. 65472 => 'ACCRA ',
  352. 67341 => ' MAPUTO ',
  353. 68368 => 'JOHANNESBURG ',
  354. 68396 => 'MANZINI ',
  355. 68816 => 'CAPE TOWN ',
  356. 71624 => 'TORONTO ' ,
  357. 71627 => 'MONTREAL ',
  358. 71628 => 'OTTAWA ',
  359. 71892 => 'VANCOUVER ',
  360. 72202 => 'MIAMI ',
  361. 72219 => 'ATLANTA ' ,
  362. 72243 => 'HOUSTON ',
  363. 72295 => 'LOS ANGELES ',
  364. 72386 => 'LAS VEGAS ',
  365. 72403 => 'WASHINGTON DC ',
  366. 72503 => 'NEW YORK ',
  367. 72509 => 'BOSTON ',
  368. 72530 => 'CHICAGO ',
  369. 72793 => 'SEATTLE ',
  370. 78264 => 'SANTIAGO DE CUBA ' ,
  371. 80222 => 'BOGOTA ',
  372. 84628 => 'LIMA ',
  373. 85799 => 'PUERTO MONTT ',
  374. 87585 => 'BUENOS AIRES ' ,
  375. 93110 => 'AUCKLAND ',
  376. 93436 => 'WELLINGTON ',
  377. 94767 => 'SYDNEY ',
  378. 94868 => 'MELBOURNE ',
  379. 94926 => 'CANBERRA ' ,
  380. 59279 => 'Foshan',
  381. 53753 => 'Lüliang',
  382. 51431 => 'Yining');
  383. ?>
Copy code
  1. header('Content-type:text/html;charset=utf-8');
  2. require_once 'city.php';
  3. @error_reporting(0);
  4. if($_POST['submit'] === 'OK')
  5. {
  6. $client = new SoapClient('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl');
  7. $code = $_POST['city'];
  8. //$code = '深圳';
  9. $para = array('theCityName'=>$code);
  10. $res = $client->__Call('getWeatherbyCityName',array('paramters'=>$para))->getWeatherbyCityNameResult->string;
  11. echo "
    ";</li>
    <li>	echo "城市:".$res[1];</li>
    <li>	echo "<br/>气温:".$res[5];</li>
    <li>	echo "<br/>天气:".$res[6];</li>
    <li>	echo "<br/>风力:".$res[7];</li>
    <li>	echo "
    ";
  12. //$qq = $_POST['qqnum'];
  13. $qq = '260558820';
  14. if(!empty($qq))
  15. {
  16. if(preg_match('/^d+$/',$qq))
  17. {
  18. $client = new SoapClient('http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl',array('trace'=>1));
  19. $para = array('qqCode'=>$qq);
  20. $res = $client->__Call('qqCheckOnline',array('paramters'=>$para))->qqCheckOnlineResult;
  21. echo $qq.' 目前'.($res=='Y'?'在线':'离线');
  22. }
  23. else
  24. {
  25. echo '错误的qq号码';
  26. }
  27. }
  28. }
  29. ?>
  30. 天气预报查询:

  31. QQ在线查询:
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn