首頁 >後端開發 >php教程 >一個SOAP Client的簡單測試(帶測試實例)

一個SOAP Client的簡單測試(帶測試實例)

WBOY
WBOY原創
2016-07-25 09:08:551756瀏覽
自己收集整理的程式碼,簡單的實現天氣及QQ線上查詢。僅供參考,歡迎拍磚。
  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. 54511 => '北京 ',
  8. 58367 => '上海 ',
  9. 54517 => '天津 ',
  10. 57516 => '重庆 ',
  11. 45005 => '香港 ',
  12. 45011 => '澳门 ',
  13. 50953 => '哈尔滨 ',
  14. 50745 => '齐齐哈尔 ',
  15. 54094 => '牡丹江 ',
  16. 50842 => '大庆 ',
  17. 50774 => '伊春 ',
  18. 50884 => '双鸭山 ',
  19. 50775 => '鹤岗 ',
  20. 50978 => '鸡西 ',
  21. 50873 => '佳木斯 ',
  22. 50971 => '七台河 ',
  23. 50468 => '黑河 ',
  24. 50853 => '绥化 ',
  25. 50442 => '大兴安岭 ',
  26. 54161 => '长春 ',
  27. 54172 => '吉林 ',
  28. 54371 => '白山 ',
  29. 50936 => '白城 ',
  30. 54157 => '四平 ',
  31. 50946 => '松原 ',
  32. 54260 => '辽源 ',
  33. 50945 => '大安 ',
  34. 54363 => '通化 ',
  35. 54342 => '沈阳 ',
  36. 54662 => '大连 ',
  37. 54453 => '葫芦岛 ',
  38. 54660 => '旅顺 ',
  39. 54346 => '本溪 ',
  40. 54353 => '抚顺 ',
  41. 54249 => '铁岭 ',
  42. 54347 => '辽阳 ',
  43. 54471 => '营口 ',
  44. 54237 => '阜新 ',
  45. 54324 => '朝阳 ',
  46. 54337 => '锦州 ',
  47. 54497 => '丹东 ',
  48. 54339 => '鞍山 ',
  49. 53463 => '呼和浩特 ',
  50. 54102 => '锡林浩特 ',
  51. 53446 => '包头 ',
  52. 54218 => '赤峰 ',
  53. 50527 => '海拉尔 ',
  54. 53512 => '乌海 ',
  55. 53543 => '鄂尔多斯 ',
  56. 54135 => '通辽 ',
  57. 53698 => '石家庄 ',
  58. 54534 => '唐山 ',
  59. 54401 => '张家口 ',
  60. 54515 => '廊坊 ',
  61. 53798 => '邢台 ',
  62. 53892 => '邯郸 ',
  63. 54616 => '沧州 ',
  64. 54702 => '衡水 ',
  65. 54423 => '承德 ',
  66. 54602 => '保定 ',
  67. 54449 => '秦皇岛 ',
  68. 57083 => '郑州 ',
  69. 57091 => '开封 ',
  70. 57073 => '洛阳 ',
  71. 57171 => '平顶山 ',
  72. 53982 => '焦作 ',
  73. 53990 => '鹤壁 ',
  74. 53986 => '新乡 ',
  75. 53898 => '安阳 ',
  76. 54900 => '濮阳 ',
  77. 57089 => '许昌 ',
  78. 57186 => '漯河 ',
  79. 57051 => '三门峡 ',
  80. 57178 => '南阳 ',
  81. 58005 => '商丘 ',
  82. 57297 => '信阳 ',
  83. 57195 => '周口 ',
  84. 57290 => '驻马店 ',
  85. 54823 => '济南 ',
  86. 54857 => '青岛 ',
  87. 54830 => '淄博 ',
  88. 54774 => '威海 ',
  89. 54918 => '曲阜 ',
  90. 54938 => '临沂 ',
  91. 54765 => '烟台 ',
  92. 58024 => '枣庄 ',
  93. 54806 => '聊城 ',
  94. 54915 => '济宁 ',
  95. 54906 => '菏泽 ',
  96. 54827 => '泰安 ',
  97. 54945 => '日照 ',
  98. 54736 => '东营 ',
  99. 54714 => '德州 ',
  100. 54734 => '滨州 ',
  101. 54828 => '莱芜 ',
  102. 54843 => '潍坊 ',
  103. 53772 => '太原 ',
  104. 53782 => '阳泉 ',
  105. 53976 => '晋城 ',
  106. 53778 => '晋中 ',
  107. 53868 => '临汾 ',
  108. 53959 => '运城 ',
  109. 53882 => '长治 ',
  110. 53578 => '朔州 ',
  111. 53674 => '忻州 ',
  112. 53487 => '大同 ',
  113. 58238 => '南京 ',
  114. 58357 => '苏州 ',
  115. 58356 => '昆山 ',
  116. 58259 => '南通 ',
  117. 58377 => '太仓 ',
  118. 58349 => '吴县 ',
  119. 58027 => '徐州 ',
  120. 58346 => '宜兴 ',
  121. 58248 => '镇江 ',
  122. 58145 => '淮安 ',
  123. 58352 => '常熟 ',
  124. 58151 => '盐城 ',
  125. 58246 => '泰州 ',
  126. 58354 => '无锡 ',
  127. 58044 => '连云港 ',
  128. 58245 => '扬州 ',
  129. 58343 => '常州 ',
  130. 58131 => '宿迁 ',
  131. 58321 => '合肥 ',
  132. 58326 => '巢湖 ',
  133. 58221 => '蚌埠 ',
  134. 58424 => '安庆 ',
  135. 58311 => '六安 ',
  136. 58236 => '滁州 ',
  137. 58336 => '马鞍山 ',
  138. 58203 => '阜阳 ',
  139. 58433 => '宣城 ',
  140. 58429 => '铜陵 ',
  141. 58116 => '淮北 ',
  142. 58334 => '芜湖 ',
  143. 58122 => '宿州 ',
  144. 58224 => '淮南 ',
  145. 58427 => '池州 ',
  146. 57036 => '西安 ',
  147. 53955 => '韩城 ',
  148. 57245 => '安康 ',
  149. 57127 => '汉中 ',
  150. 57016 => '寶雞',
  151. 57048 => '鹹陽',
  152. 53646 => '榆林',
  153. 57045 => '渭南',
  154. 57143 = '商53947 => '銅川',
  155. 53845 => '延安',
  156. 53614 => '銀川',
  157. 53817 => '固原',
  158. 53704 => '中衛',
  159. '中衛',
  160. '中衛',
  161. '中衛',
  162. '中衛',
  163. '中衛',
  164. '中衛',
  165. '中衛',
  166. '中衛',
  167. '中衛',
  168. 53518 => '石嘴山',
  169. 53612 => '吳忠',
  170. 52889 => '蘭州',
  171. 52896 => '白銀',
  172. 53829 => '慶陽',
  173. 53829 => '慶陽',
  174. 53829 => '慶陽',
  175. 53829 => '慶陽',
  176. > 52533 => '酒泉',
  177. 57006 => '天水',
  178. 52679 => '武威',
  179. 52652 => '張掖',
  180. 50741 => '甘南' > 52984 => '臨夏',
  181. 53915 => '平涼',
  182. 52995 => '定西',
  183. 52675 => '金昌',
  184. 52866 => '西寧',
  185. 52866 => '西寧',
  186. 52866 => '西寧',
  187. 52754 => '海北',
  188. 52737 => '海西',
  189. 56065 => '黃南',
  190. 56043 => '果洛',
  191. 56029 => '玉樹' ,
  192. 52875 => '海東',
  193. 52856 => '海南',
  194. 57494 => '武漢',
  195. 57461 => '宜昌',
  196. 57498 => '宜昌> ',
  197. 57447 => '恩施',
  198. 57476 => '荊州',
  199. 57362 => '神農架',
  200. 57256 => '十堰',
  201. 57590> 57590 => '十堰',
  202. 57590 ',
  203. 57278 => '襄樊',
  204. 57482 => '孝感',
  205. 57381 => '隨州',
  206. 58407 => '黃門荊石', 57496 => '鄂州',
  207. 57679 => '長沙',
  208. 57766 => '邵陽',
  209. 57662 => '常德',
  210. 57972 => '常德',
  211. 57972 = 鎜> ',
  212. 57649 => '吉首',
  213. 57780 => '株洲',
  214. 57763 => '婁底',
  215. 57773 => '柹潭', 57866 => '永州',
  216. 57584 => '岳陽',
  217. 57872 => '衡陽',
  218. 57749 => '懷化',
  219. 57771 = 韶山> ',
  220. 57558 => '張家界',
  221. 58457 => '杭州',
  222. 58450 => '湖州',
  223. 58549 => '金波華',
  224. 585633 ',
  225. 58646 => '麗水',
  226. 58453 => '紹興',
  227. 58633 => '衢州',
  228. 58452 => '嘉興台州, 586600 ',
  229. 58477 => '舟山',
  230. 58659 => '溫州',
  231. 58606 => '南昌',
  232. 57786 => '萍^ ',
  233. 58637 => '上饒',
  234. 58617 => '撫州',
  235. 57799 => '吉安',
  236. 58627 => '鷹潭',
  237. 57793 => ' 5793 ',
  238. 57796 => '新餘',
  239. 58527 => '景德鎮',
  240. 57993 => '贛州',
  241. 58847 => '福州', 58927 => '龍岩',
  242. 58834 => '南平',
  243. 58846 => '寧德',
  244. 58946 => '田',
  245. ' 59137 ',
  246. 58828 => '三明',
  247. 59126 => '漳州',
  248. 57816 => '貴陽',
  249. 57806 => '安順水',
  250. 57609 ',
  251. 57713 => '遵義',
  252. 57741 => '銅仁',
  253. 56693 => '六盤水',
  254. 57707 => '畢節',
  255. 578255 =>裡',
  256. 57827 => '都勻',
  257. 56294 => '成都',
  258. 57602 => '瀘州',
  259. 57504 => '內江', '涼山',
  260. 56171 => '阿壩',
  261. 57313 => '巴中',
  262. 57206 => '廣元',
  263. 56386 => '樂山', '綿陽',
  264. 56198 => '德陽',
  265. 56666 => '攀枝花',
  266. 56287 => '雅安',
  267. 56492 => '宜賓',
  268. 5
  269. 56492 => '宜賓',
  270. 5 > '自貢',
  271. 56146 => '甘孜州',
  272. 57328 => '達州',
  273. 56298 => '資陽',
  274. 57415 => '廣安',
  275. 5
  276. 57415 => '廣安',
  277. 5
  278. 57415 => '廣安',
  279. 5
  280. 57415 => '廣安',
  281. 5
  282. 57415 => '廣安',
  283. 5
  284. 57415 => '廣安',
  285. 5 => '遂寧',
  286. 56391 => '眉山',
  287. 57411 => '南充',
  288. 59287 => '廣州',
  289. 59493 => '深圳',
  290. 593312 => '潮州',
  291. 59082 => '韶關',
  292. 59658 => '湛江',
  293. 59298 => '惠州',
  294. 59280 => '清遠', '東莞',
  295. 59473 => '江門',
  296. 59659 => '茂名',
  297. 59278 => '肇慶',
  298. 59501 => '江尾', => '河源',
  299. 59315 => '揭陽',
  300. 59117 => '梅州',
  301. 59485 => '中山',
  302. 59269 => '德慶', 59663 => '陽江', 59471 => '雲浮', 59488 => '珠海', 59316 => '汕頭', 59431 => '南寧', 57957 => '桂林', 59051 => '陽朔', 59046 => '柳州', 59265 => '梧州', 59453 => '玉林', '玉林', '玉林', ' 59254 => '桂平', 59065 => '賀州', 59632 => '欽州', 59249 => '貴港', 59635 => '防城港', 59635 => '防城港', '百色',59644 => '北海',
  303. 59023 => '河池',
  304. 59242 => '來賓',
  305. 59425 => '崇左',
  306. 56778 => '昆明',
  307. 56748 => '保山',
  308. 56768 => '楚雄',
  309. 56844 => '德宏',
  310. 56975 => '紅河',
  311. 56951 => '臨滄',
  312. 56533 => '怒江',
  313. 56783 => '曲靖',
  314. 56964 => '思茅',
  315. 56994 => '文玉山',
  316. 56875 = '文玉溪'
  317. 56586 => '昭通',
  318. 56651 => '麗江',
  319. 56751 => '大理',
  320. 59758 => '海口亞',
  321. 59948 = '三亞亞',
  322. 59948 = '三亞亞'
  323. 59845 => '儋州',
  324. 59757 => '瓊山',
  325. 59941 => '通甚',
  326. 59856 => '文昌',
  327. 51463 => '文昌',
  328. 51463 => '烏魯木齊',
  329. 51076 => '阿勒泰',
  330. 51628 => '阿克蘇',
  331. 51368 => '昌吉',
  332. 52203 => '哈密',
  333. '5182和田',
  334. 51709 => '喀什',
  335. 51243 => '克拉瑪依',
  336. 51356 => '石河子',
  337. 51133 => '塔城',
  338. 51🎜> 51133 => '塔城',
  339. '庫爾勒',
  340. 51573 => '吐魯番',
  341. 55591 => '拉薩',
  342. 55437 => '阿里',
  343. 56137 => '昌都', 55299> '那曲',
  344. 55578 => '日喀則',
  345. 55598 => '山南',
  346. 56312 => '林芝',
  347. 58968 => '台北', '高雄',
  348. 17060 => '伊斯坦堡ISTANBUL ',
  349. 40754 => '德黑蘭TEHRAN ',
  350. 41781 => '卡拉奇KARACHI ',
  351. 42182 = '新德里W. 🎜> 43466 => '科倫坡COLOMBO ',
  352. 47108 => '漢城SEOUL ',
  353. 47159 => '山BUSAN ',
  354. 47662 => '東京TOKYO ', 48454 => '曼谷BANGKOK ',
  355. 48647 => '吉隆坡KUALA LUMPUR ',
  356. 48820 => '河內HA NOI ',
  357. 96745 = 'AOI ' ,
  358. 10141 => '漢堡HAMBURG ',
  359. 10381 => '柏林BERLIN ',
  360. 10637 => '法蘭克福FRANKFURT ',
  361. 11034 => '維也納VIENNA ,FURT ',
  362. 11034 => '維也納VIENNA. > '米蘭MILANO ',
  363. 16235 => '羅馬ROMA ',
  364. 16701 => '雅典ATHENS ',
  365. 2484 => '斯德哥爾摩STOCKHOLM ',
  366. 27612 => '斯德哥爾摩
  367. 3334 => '曼徹斯特MANCHESTER ',
  368. 3779 => '倫敦LONDON ',
  369. 6240 => '阿姆斯特丹AMSTERDAM ',
  370. 6451 => '布魯塞爾BRUSSELES ',
  371. 6660 => 6660 '蘇黎世ZURICH ',
  372. 6700 => '日內瓦GENEVE ',
  373. 61291 => '巴馬科BAMAKO ',
  374. 63450 => '亞的斯亞貝巴ADDIS ABABA ',
  375. 63450 => '亞的斯亞貝巴ADDIS ABABA ',
  376. 63740 => '內羅畢NAIROBI ',
  377. 65472 => '阿克拉ACCRA ',
  378. 67341 => '馬普托MAPUTO ',
  379. 68368 => '約翰尼斯堡JOHANNESBURG ',
  380. 68368 => '約翰尼斯堡JOHANNESBURG ',
  381. '68396 = '曼齊尼MANZINI ',
  382. 68816 => '開普敦CAPE TOWN ',
  383. 71624 => '多倫多TORONTO ',
  384. 71627 => '蒙特利爾MONTREAL ',
  385. 716288 OTTAWA ',
  386. 71892 => '溫哥華VANCOUVER ',
  387. 72202 => '邁阿密MIAMI ',
  388. 72219 => '亞特蘭大ATLANTA ',
  389. 72243 => '休士頓HOUSTON, ' 72295 => '洛杉磯LOS ANGELES ',
  390. 72386 => '拉斯維加斯LAS VEGAS ',
  391. 72403 => '華盛頓WASHINGTON DC ',
  392. 72503 => '紐約NEW YORK ',
  393. 72509 => '波士頓BOSTON ',
  394. 72530 => '芝加哥CHICAGO ',
  395. 72793 => '西雅圖SEATTLE ',
  396. 78264 => '聖地牙哥SANTIAGO DE CUBA ',
  397. 78264 => '聖地牙哥SANTIAGO DE CUBA ',
  398. 80264 => > '波哥大BOGOTA ',
  399. 84628 => '利馬LIMA ',
  400. 85799 => '蒙特港PUERTO MONTT ',
  401. 87585 => '布宜諾斯艾利斯BUENOS AIRES ',
  402. 93110 => '奧克蘭AUCKLAND ',
  403. 93436 => '威靈頓WELLINGTON ',
  404. 94767 => '雪梨SYDNEY ',
  405. 94868 => '墨爾本MELBOURNE ' 9426 = '326 =>坎培拉CANBERRA ',
  406. 59279 => '佛山',
  407. 53753 => '呂梁',
  408. 51431 => '伊寧');
?>
複製程式碼
  1. header('Content-type:text/html;charset=utf-8');
  2. require_once 'city.php'
  3. @error_reporting(0);
  4. if($_POST['submit'] === '確定')
  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 "
    " ;
  12. echo "城市:".$res[1];
  13. echo "
    黃昏:".$res[5];
  14. echo "
    天氣:".$ res[6];
  15. echo "
    風力:".$res[7];
  16. echo "";
  17. //$qq = $_POST['qqnum'] ;
  18. $qq = '260558820';
  19. if(!empty($qq))
  20. {
  21. if(preg_match('/^) d+$/',$qq))
  22. {
  23. $client = new SoapClient('http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl',array('trace'= >1));
  24. $para = 陣列('qqCode'=>$qq);
  25. $res = $client->__Call('qqCheckOnline',array('paramters'=>$ para))->qqCheckOnlineResult;
  26. echo $qq.' 目前'.($res=='Y'?'在線':'離線');
  27. }
  28. else
  29. {
  30. echo 'QQ號碼錯誤 ;' ;
  31. }
  32. }
  33. }
  34. ?>
  35. 狀態查詢:

  36. gt;
  37. QQ線上查詢:
複製程式碼


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn