A simple test of a SOAP client (with a test instance)

Source: Internet
Author: User
Tags soap soap client wsdl
Collect and organize the code, simple implementation of the weather and QQ online query. For reference only, welcome to shoot bricks.
  1. /*generate at Sun, Jan 2009 13:46:27 +0000
  2. Don ' t Modify me!
  3. Cache Name Citys
  4. Key:a5819c80f61198eabf3d3ffceec595de
  5. */
  6. $Citys =array (
  7. 54511 = ' Beijing ',
  8. 58367 = ' Shanghai ',
  9. 54517 = ' Tianjin ',
  10. 57516 = ' Chongqing ',
  11. 45005 = ' Hong Kong ',
  12. 45011 = ' Macau ',
  13. 50953 = ' Harbin ',
  14. 50745 = ' Qiqihar ',
  15. 54094 = ' Mudanjiang ',
  16. 50842 = ' Daqing ',
  17. 50774 = ' Yichun ',
  18. 50884 = ' Shuangyashan ',
  19. 50775 = ' Hegang ',
  20. 50978 = ' Jixi ',
  21. 50873 = ' Jiamusi ',
  22. 50971 = ' Qitaihe ',
  23. 50468 = ' Heihe ',
  24. 50853 = ' Suihua ',
  25. 50442 = ' daxinganling ',
  26. 54161 = ' Changchun ',
  27. 54172 = ' Jilin ',
  28. 54371 = ' Bss ',
  29. 50936 = ' Baicheng ',
  30. 54157 = ' Siping ',
  31. 50946 = ' Songyuan ',
  32. 54260 = ' Liaoyuan ',
  33. 50945 = ' Daan ',
  34. 54363 = ' Tonghua ',
  35. 54342 = ' Shenyang ',
  36. 54662 = ' Dalian ',
  37. 54453 = ' Huludao ',
  38. 54660 = ' Arthur ',
  39. 54346 = ' Benxi ',
  40. 54353 = ' Fushun ',
  41. 54249 = ' Tieling ',
  42. 54347 = ' Liaoyang ',
  43. 54471 = ' Yingkou ',
  44. 54237 = ' Fuxin ',
  45. 54324 = ' Chaoyang ',
  46. 54337 = ' Jinzhou ',
  47. 54497 = ' Dandong ',
  48. 54339 = ' Anshan ',
  49. 53463 = ' Hohhot ',
  50. 54102 = ' Xilin Hot ',
  51. 53446 = ' Baotou ',
  52. 54218 = ' Chifeng ',
  53. 50527 = ' Hailar ',
  54. 53512 = ' Wuhai ',
  55. 53543 = ' Ordos ',
  56. 54135 = ' Tongliao ',
  57. 53698 = ' Shijiazhuang ',
  58. 54534 = ' Tangshan ',
  59. 54401 = ' Zhangjiakou ',
  60. 54515 = ' Langfang ',
  61. 53798 = ' Xingtai ',
  62. 53892 = ' Handan ',
  63. 54616 = ' Cangzhou ',
  64. 54702 = ' Hengshui ',
  65. 54423 = ' Chengde ',
  66. 54602 = ' Baoding ',
  67. 54449 = ' Qinhuangdao ',
  68. 57083 = ' Zhengzhou ',
  69. 57091 = ' Kaifeng ',
  70. 57073 = ' Luoyang ',
  71. 57171 = ' Mesa ',
  72. 53982 = ' Jiaozuo ',
  73. 53990 = ' Hebi ',
  74. 53986 = ' Xinxiang ',
  75. 53898 = ' Anyang ',
  76. 54900 = ' Puyang ',
  77. 57089 = ' Xuchang ',
  78. 57186 = ' Luohe ',
  79. 57051 = ' Sanmenxia ',
  80. 57178 = ' Nanyang ',
  81. 58005 = ' Shangqiu ',
  82. 57297 = ' Xinyang ',
  83. 57195 = ' Zhoukou ',
  84. 57290 = ' Zhumadian ',
  85. 54823 = ' Jinan ',
  86. 54857 = ' Qingdao ',
  87. 54830 = ' Zibo ',
  88. 54774 = ' Weihai ',
  89. 54918 = ' Qufu ',
  90. 54938 = ' Linyi ',
  91. 54765 = ' Yantai ',
  92. 58024 = ' Zaozhuang ',
  93. 54806 = ' Liaocheng ',
  94. 54915 = ' Jining ',
  95. 54906 = ' Heze ',
  96. 54827 = ' Taian ',
  97. 54945 = ' Rizhao ',
  98. 54736 = ' dongying ',
  99. 54714 = ' Texas ',
  100. 54734 = ' Binzhou ',
  101. 54828 = ' Laiwu ',
  102. 54843 = ' Weifang ',
  103. 53772 = ' Taiyuan ',
  104. 53782 = ' Yangquan ',
  105. 53976 = ' Jincheng ',
  106. 53778 = ' Jinzhong ',
  107. 53868 = ' Linfen ',
  108. 53959 = ' Yuncheng ',
  109. 53882 = ' Changzhi ',
  110. 53578 = ' Shuozhou ',
  111. 53674 = ' Xinzhou ',
  112. 53487 = ' Datong ',
  113. 58238 = ' Nanjing ',
  114. 58357 = ' Suzhou ',
  115. 58356 = ' Kunshan ',
  116. 58259 = ' Nantong ',
  117. 58377 = ' Taicang ',
  118. 58349 = ' Wu County ',
  119. 58027 = ' Xuzhou ',
  120. 58346 = ' Yixing ',
  121. 58248 = ' Zhenjiang ',
  122. 58145 = ' Huaian ',
  123. 58352 = ' Changshu ',
  124. 58151 = ' Yancheng ',
  125. 58246 = ' Taizhou ',
  126. 58354 = ' Wuxi ',
  127. 58044 = ' Lianyungang ',
  128. 58245 = ' Yangzhou ',
  129. 58343 = ' Changzhou ',
  130. 58131 = ' Suqian ',
  131. 58321 = ' Hefei ',
  132. 58326 = ' Chaohu ',
  133. 58221 = ' Bengbu ',
  134. 58424 = ' Anqing ',
  135. 58311 = ' Liu'an ',
  136. 58236 = ' Chuzhou ',
  137. 58336 = ' ma On Shan ',
  138. 58203 = ' Fuyang ',
  139. 58433 = ' Xuancheng ',
  140. 58429 = ' Tongling ',
  141. 58116 = ' Huaibei ',
  142. 58334 = ' Wuhu ',
  143. 58122 = ' Suzhou ',
  144. 58224 = ' Huainan ',
  145. 58427 = ' Chizhou ',
  146. 57036 = ' Xian ',
  147. 53955 = ' Hancheng ',
  148. 57245 = ' Ankang ',
  149. 57127 = ' Hanzhong ',
  150. 57016 = ' Baoji ',
  151. 57048 = ' Xianyang ',
  152. 53646 = ' Yulin ',
  153. 57045 = ' Weinan ',
  154. 57143 = ' Shangluo ',
  155. 53947 = ' Tongchuan ',
  156. 53845 = ' Yanan ',
  157. 53614 = ' Yinchuan ',
  158. 53817 = ' Guyuan ',
  159. 53704 = ' Zhongwei ',
  160. 53518 = ' Shizuishan ',
  161. 53612 = ' Wuzhong ',
  162. 52889 = ' Lanzhou ',
  163. 52896 = ' Silver ',
  164. 53829 = ' Qingyang ',
  165. 52533 = ' Jiuquan ',
  166. 57006 = ' Tianshui ',
  167. 52679 = ' Wuwei ',
  168. 52652 = ' Zhangye ',
  169. 50741 = ' Gannan ',
  170. 52984 = ' Linxia ',
  171. 53915 = ' Pingliang ',
  172. 52995 = ' Dingxi ',
  173. 52675 = ' Jinchang ',
  174. 52866 = ' Xining ',
  175. 52754 = ' sea North ',
  176. 52737 = ' Hercynian ',
  177. 56065 = ' Huangnan ',
  178. 56043 = ' Fruit Luo ',
  179. 56029 = ' Yushu ',
  180. 52875 = ' Haidong ',
  181. 52856 = ' Hainan ',
  182. 57494 = ' Wuhan ',
  183. 57461 = ' Yichang ',
  184. 57498 = ' Huanggang ',
  185. 57447 = ' Enshi ',
  186. 57476 = ' Jingzhou ',
  187. 57362 = ' Shennongjia ',
  188. 57256 = ' Shiyan ',
  189. 57590 = ' xianning ',
  190. 57278 = ' Xiangfan ',
  191. 57482 = ' Xiaogan ',
  192. 57381 = ' Suizhou ',
  193. 58407 = ' Yellowstone ',
  194. 57377 = ' Jingmen ',
  195. 57496 = ' Ezhou ',
  196. 57679 = ' Changsha ',
  197. 57766 = ' Shaoyang ',
  198. 57662 = ' Changde ',
  199. 57972 = ' Chenzhou ',
  200. 57649 = ' Jishou ',
  201. 57780 = ' Zhuzhou ',
  202. 57763 = ' Loudi ',
  203. 57773 = ' Xiangtan ',
  204. 57674 = ' Yiyang ',
  205. 57866 = ' Yongzhou ',
  206. 57584 = ' Yueyang ',
  207. 57872 = ' Hengyang ',
  208. 57749 = ' Huaihua ',
  209. 57771 = ' Shaoshan ',
  210. 57558 = ' Zhangjiajie ',
  211. 58457 = ' Hangzhou ',
  212. 58450 = ' Huzhou ',
  213. 58549 = ' Jinhua ',
  214. 58563 = ' Ningbo ',
  215. 58646 = ' Yeosu ',
  216. 58453 = ' Shaoxing ',
  217. 58633 = ' Quzhou ',
  218. 58452 = ' Jiaxing ',
  219. 58660 = ' Taizhou ',
  220. 58477 = ' Zhoushan ',
  221. 58659 = ' Wenzhou ',
  222. 58606 = ' Nanchang ',
  223. 57786 = ' Pingxiang ',
  224. 58502 = ' Jiujiang ',
  225. 58637 = ' Shangrao ',
  226. 58617 = ' Fuzhou ',
  227. 57799 = ' Jian ',
  228. 58627 = ' Yingtan ',
  229. 57793 = ' Yichun ',
  230. 57796 = ' Xinyu ',
  231. 58527 = ' Jingdezhen ',
  232. 57993 = ' Ganzhou ',
  233. 58847 = ' Fuzhou ',
  234. 59134 = ' Xiamen ',
  235. 58927 = ' Longyan ',
  236. 58834 = ' Nanping ',
  237. 58846 = ' Ningde ',
  238. 58946 = ' Putian ',
  239. 59137 = ' Quanzhou ',
  240. 58828 = ' sanming ',
  241. 59126 = ' Zhangzhou ',
  242. 57816 = ' Guiyang ',
  243. 57806 = ' Anshun ',
  244. 57609 = ' Chishui ',
  245. 57713 = ' Zunyi ',
  246. 57741 = ' Tongren ',
  247. 56693 = ' Liupanshui ',
  248. 57707 = ' Bijie ',
  249. 57825 = ' Carey ',
  250. 57827 = ' Duyun ',
  251. 56294 = ' Chengdu ',
  252. 57602 = ' Luzhou ',
  253. 57504 = ' Neijiang ',
  254. 56571 = ' Liangshan ',
  255. 56171 = ' Aba ',
  256. 57313 = ' Bazhong ',
  257. 57206 = ' Guangyuan ',
  258. 56386 = ' Leshan ',
  259. 56196 = ' Mianyang ',
  260. 56198 = ' Deyang ',
  261. 56666 = ' Panzhihua ',
  262. 56287 = ' Yaan ',
  263. 56492 = ' Yibin ',
  264. 56396 = ' Zigong ',
  265. 56146 = ' Ganzi Prefecture ',
  266. 57328 = ' Dazhou ',
  267. 56298 = ' Ziyang ',
  268. 57415 = ' Guang ',
  269. 57405 = ' Suining ',
  270. 56391 = ' Meishan ',
  271. 57411 = ' Nanchong ',
  272. 59287 = ' Guangzhou ',
  273. 59493 = ' Shenzhen ',
  274. 59312 = ' Chaozhou ',
  275. 59082 = ' Shaoguan ',
  276. 59658 = ' Zhanjiang ',
  277. 59298 = ' Huizhou ',
  278. 59280 = ' Qingyuan ',
  279. 59289 = ' Dongguan ',
  280. 59473 = ' Jiangmen ',
  281. 59659 = ' Maoming ',
  282. 59278 = ' zhaoqing ',
  283. 59501 = ' Shanwei ',
  284. 59293 = ' Heyuan ',
  285. 59315 = ' Jieyang ',
  286. 59117 = ' Meizhou ',
  287. 59485 = ' Zhongshan ',
  288. 59269 = ' Deqing ',
  289. 59663 = ' Yangjiang ',
  290. 59471 = ' Yunfu ',
  291. 59488 = ' Zhuhai ',
  292. 59316 = ' Shantou ',
  293. 59431 = ' Nanning ',
  294. 57957 = ' Guilin ',
  295. 59051 = ' Yangshuo ',
  296. 59046 = ' Liuzhou ',
  297. 59265 = ' Wuzhou ',
  298. 59453 = ' Yulin ',
  299. 59254 = ' guiping ',
  300. 59065 = ' Hezhou ',
  301. 59632 = ' Qinzhou ',
  302. 59249 = ' Guigang ',
  303. 59635 = ' Fangchenggang ',
  304. 59211 = ' Baise ',
  305. 59644 = ' Beihai ',
  306. 59023 = ' Hechi ',
  307. 59242 = ' guest ',
  308. 59425 = ' Chongzuo ',
  309. 56778 = ' Kunming ',
  310. 56748 = ' Baoshan ',
  311. 56768 = ' Chuxiong ',
  312. 56844 = ' de macro ',
  313. 56975 = ' Red River ',
  314. 56951 = ' Lincang ',
  315. 56533 = ' Nujiang ',
  316. 56783 = ' Qujing ',
  317. 56964 = ' Simao ',
  318. 56994 = ' Wenshan ',
  319. 56875 = ' Yuxi ',
  320. 56586 = ' Zhaotong ',
  321. 56651 = ' Lijiang ',
  322. 56751 = ' Dali ',
  323. 59758 = ' Haikou ',
  324. 59948 = ' Sanya ',
  325. 59845 = ' Zhanzhou ',
  326. 59757 = ' Qiongshan ',
  327. 59941 = ' Tong-shi ',
  328. 59856 = ' Wenchang ',
  329. 51463 = ' Urumqi ',
  330. 51076 = ' Altay ',
  331. 51628 = ' Akzo ',
  332. 51368 = ' Changji ',
  333. 52203 = ' Hami ',
  334. 51828 = ' Hetian ',
  335. 51709 = ' Kashgar ',
  336. 51243 = ' Karamay ',
  337. 51356 = ' Shihezi ',
  338. 51133 = ' Tacheng ',
  339. 51656 = "Korla",
  340. 51573 = ' Turpan ',
  341. 55591 = ' Lhasa ',
  342. 55437 = ' Ali ',
  343. 56137 = ' The ",
  344. 55299 = ' A ',
  345. 55578 = ' Shigatse ',
  346. 55598 = ' Shannan ',
  347. 56312 = ' Linzhi ',
  348. 58968 = ' Taipei ',
  349. 59554 = ' Kaohsiung ',
  350. 17060 = ' Istanbul ISTANBUL ',
  351. 40754 = ' Tehran TEHRAN ',
  352. 41781 = ' Karachi KARACHI ',
  353. 42182 = ' New DELHI new DELHI ',
  354. 43466 = ' Colombo COLOMBO ',
  355. 47108 = ' Seoul SEOUL ',
  356. 47159 = ' Busan BUSAN ',
  357. 47662 = ' Tokyo Tonkin ',
  358. 48097 = ' Yangon YANGON ',
  359. 48454 = ' Bangkok BANGKOK ',
  360. 48647 = ' Kuala Lumpur KUALA Lumpur ',
  361. 48820 = ' Hanoi HA NOI ',
  362. 96745 = ' Jakarta JAKARTA ',
  363. 10141 = ' Hamburg HAMBURG ',
  364. 10381 = ' Berlin BERLIN ',
  365. 10637 = ' Frankfurt FRANKFURT ',
  366. 11034 = ' Vienna VIENNA ',
  367. 16066 = ' Milan MILANO ',
  368. 16235 = ' Roma Roma ',
  369. 16701 = ' Athens ATHENS ',
  370. 2484 = ' Stockholm STOCKHOLM ',
  371. 27612 = ' Moscow Moskva ',
  372. 3334 = ' Manchester MANCHESTER ',
  373. 3779 = ' London ',
  374. 6240 = ' Amsterdam AMSTERDAM ',
  375. 6451 = ' Brussels brusseles ',
  376. 6660 = ' Zurich ZURICH ',
  377. 6700 = ' Geneva GENEVE ',
  378. 61291 = ' Bamako Bamako ',
  379. 63450 = ' Addis Ababa ADDIS Ababa ',
  380. 63740 = ' Nairobi Nairobi ',
  381. 65472 = ' Accra Accra ',
  382. 67341 = ' Maputo MAPUTO ',
  383. 68368 = ' Johannesburg Johannesburg ',
  384. 68396 = ' Manzini Manzini ',
  385. 68816 ' Cape Town ',
  386. 71624 = ' Toronto TORONTO ',
  387. 71627 = ' Montreal MONTREAL ',
  388. 71628 = ' Ottawa OTTAWA ',
  389. 71892 = ' Vancouver VANCOUVER ',
  390. 72202 = ' Miami MIAMI ',
  391. 72219 = ' Atlanta ATLANTA ',
  392. 72243 = ' Houston HOUSTON ',
  393. 72295 = ' Los ANGELES ',
  394. 72386 = ' Las Vegas LAS VEGAS ',
  395. 72403 = ' Washington WASHINGTON DC ',
  396. 72503 = ' New York ',
  397. 72509 = ' Boston BOSTON ',
  398. 72530 = ' Chicago CHICAGO ',
  399. 72793 = ' Seattle SEATTLE ',
  400. 78264 = ' Santiago SANTIAGO DE CUBA ',
  401. 80222 = ' Bogota BOGOTA ',
  402. 84628 = Lima Lima ',
  403. 85799 = ' Monterey port PUERTO MONTT ',
  404. 87585 = ' Buenos Aires BUENOS AIRES ',
  405. 93110 = ' Oakland AUCKLAND ',
  406. 93436 = ' Wellington WELLINGTON ',
  407. 94767 = ' Sydney SYDNEY ',
  408. 94868 = ' Melbourne MELBOURNE ',
  409. 94926 = ' Canberra CANBERRA ',
  410. 59279 = ' Foshan ',
  411. 53753 = ' Luliang ',
  412. 51431 = ' Yining ');
  413. ?>
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 = ' Shenzhen ';
  9. $para = Array (' thecityname ' = = $code);
  10. $res = $client->__call (' Getweatherbycityname ', Array (' paramters ' = $para))->getweatherbycitynameresult- >string;
  11. echo "
    ";
  12. echo "City:". $res [1];
  13. echo "
    Temperature: ". $res [5];
  14. echo "
    Weather: ". $res [6];
  15. echo "
    Wind: ". $res [7];
  16. echo "
  17. ";
  18. $QQ = $_post[' qqnum ');
  19. $QQ = ' 260558820 ';
  20. if (!empty ($QQ))
  21. {
  22. if (Preg_match ('/^\d+$/', $QQ))
  23. {
  24. $client = new SoapClient (' http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl ', Array (' Trace ' =>1) );
  25. $para = Array (' qqcode ' = = $QQ);
  26. $res = $client->__call (' Qqcheckonline ', Array (' paramters ' = $para))->qqcheckonlineresult;
  27. echo $qq. ' Present '. ($res = = ' Y '? ' Online ': ' Offline ');
  28. }
  29. Else
  30. {
  31. Echo ' wrong QQ number ';
  32. }
  33. }
  34. }
  35. ?>
Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.