加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex访问webService获取手机号归属地

发布时间:2020-12-15 05:06:38 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"mx:Style global{ fontSize:12pt; } /mx:Stylemx:Script![CDATA[import mx.controls.Alert;import mx.rpc.events.FaultEvent;import mx.rpc
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="absolute">
	<mx:Style>
  global{
   fontSize:12pt;
  }
 </mx:Style>

	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;

			//引入远程调用的事件处理
			//向WebService发送请求

			private function sendCount():void
			{
				ws.getMobileCodeInfo(cellphoneNumber.text).send();
			}

			//显示结果的处理函数
			private function showResult(rs:ResultEvent):void
			{
				//得到返回的结果
				var rsStr:String=new String(rs.result);
				cellphoneNumberInfoText.text=rsStr;
			}

			private function faultResult(faultmessage:FaultEvent):void
			{

				var faultStr:String=new String(faultmessage.message);
				Alert.show(faultStr,"WebService访问错误");
			}

			private function go():void
			{
				navigateToURL(new URLRequest("http://www.webxml.com.cn/"),"_blank");
			}

			//清空查询的号码和信息
			private function clearText():void
			{
				cellphoneNumber.text=null;
				cellphoneNumberInfoText.text=null;
			}
		]]>
	</mx:Script>
	<!-- 引入WebService标签,设定wsdl。不使用代理名称-->
	<!--此 WebService由网站:http://www.webxml.com.cn/提供。该网站内还有其它免费web服务 -->
	<mx:WebService id="ws"
				   wsdl="http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL"
				   useProxy="false"
				   showBusyCursor="true"
				   result="showResult(event)"
				   fault="faultResult(event)">

		<mx:operation name="getMobileCodeInfo">
		</mx:operation>
	</mx:WebService>

	<mx:Panel x="296"
			  y="107"
			  width="364"
			  height="200"
			  layout="absolute"
			  title="手机归属地查询"
			  horizontalAlign="center"
			  verticalAlign="middle">
		<mx:TextInput x="92"
					  y="33"
					  id="cellphoneNumber"/>
		<mx:Button x="114"
				   y="93"
				   label="查询"
				   click="sendCount()"/>
		<mx:Text x="35"
				 y="65"
				 text=""
				 width="299"
				 id="cellphoneNumberInfoText"/>
		<mx:Button x="174"
				   y="93"
				   label="清除"
				   id="clear"
				   click="clearText()"/>
	</mx:Panel>

	<mx:Text width="321"
			 height="50"
			 x="318"
			 y="37">
		<mx:htmlText>
			<![CDATA[
       <a href="http://blog.163.com/liwei3324@126/" target=" _blank">如有不懂的地方,欢迎访问我的博客。点击我</a>
      ]]>
		</mx:htmlText>
	</mx:Text>
	<mx:Label x="135"
			  y="403"
			  text="此WebService是由网站http://www.webxml.com.cn/提供"
			  fontSize="22"
			  fontWeight="bold"
			  fontStyle="italic"/>
	<mx:LinkButton x="404"
				   y="458"
				   label="走,去看看!>>"
				   color="#1510EC"
				   click="go()"/>
</mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读