参考:http://dcec226:8399/arcgis/sdk/rest/index.html?mapserver.html
- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
- <fx:Script>
- <![CDATA[
- import mx.controls.Alert;
- import mx.rpc.events.FaultEvent;
- import mx.rpc.events.ResultEvent;
- protected function btnSend_clickHandler(event:MouseEvent):void
- {
- var params:URLVariables = new URLVariables();
- var url:String="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project";
- srv.url=url;
- params.inSR="4326";
- params.outSR="102113";
- params.geometries="{'geometryType':'esriGeometryPoint','geometries':[{'x':-117,'y':34}]}";
- params.f="pjson";
- srv.send(params);
- }
- private function gotResult(event:ResultEvent):void{
- Alert.show(event.result as String);
- }
- private function gotError(event:FaultEvent):void{
- Alert.show(event.toString());
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <mx:HTTPService id="srv" result="gotResult(event);" useProxy="false" fault="gotError(event)"/>
- </fx:Declarations>
- <s:Button id="btnSend" label="调用" click="btnSend_clickHandler(event)"/>
- </s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
protected function btnSend_clickHandler(event:MouseEvent):void
{
var params:URLVariables = new URLVariables();
var url:String="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project";
srv.url=url;
params.inSR="4326";
params.outSR="102113";
params.geometries="{'geometryType':'esriGeometryPoint','geometries':[{'x':-117,'y':34}]}";
params.f="pjson";
srv.send(params);
}
private function gotResult(event:ResultEvent):void{
Alert.show(event.result as String);
}
private function gotError(event:FaultEvent):void{
Alert.show(event.toString());
}
]]>
</fx:Script>
<fx:Declarations>
<mx:HTTPService id="srv" result="gotResult(event);" useProxy="false" fault="gotError(event)"/>
</fx:Declarations>
<s:Button id="btnSend" label="调用" click="btnSend_clickHandler(event)"/>
</s:Application>
HTTPService传送参数的第二种方式
- <fx:Declarations>
- <!-- 将非可视元素(例如服务、值对象)放在此处 -->
- <!--定义HttpService发送请求-->
- <s:HTTPService id="service"
- url="http://localhost:8080/testhttpservice/testHttpServiceServlet"
- useProxy="false"
- fault="service_faultHandler(event)"
- result="service_resultHandler(event)">
- <s:request >
- <!--参数名称作标签,中间填充参数值-->
- <username>{txtusername.text}</username>
- <password>{txtpassword.text}</password>
- </s:request>
- </s:HTTPService>
- </fx:Declarations>