Apache flex 如何使用Flex中的HttpService request thr POST将xml数据发送到服务器?

Apache flex 如何使用Flex中的HttpService request thr POST将xml数据发送到服务器?,apache-flex,Apache Flex,请告诉我示例….柔性侧: import mx.rpc.http.HTTPService; import mx.rpc.AsyncToken; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; var service:HTTPService = new HTTPService; service.useProxy = false; service.method = "post"; service.url = "[y

请告诉我示例….

柔性侧:

import mx.rpc.http.HTTPService;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

var service:HTTPService = new HTTPService;
service.useProxy = false;
service.method = "post";
service.url = "[your php]";
var params:Object = {};
params.xml = "[your xml string] <root><label = "hello world" /></root>";
var token:AsyncToken = service.send(params);
var responder:mx.rpc.Responder = new mx.rpc.Responder(onResult, onFault);
token.addResponder(responder);

private function onResult(event:ResultEvent):void{
     trace ("XML PASSED", event.result);
}
private function onFault(event:FaultEvent):void{
     trace ("XML PASSING FAILED");
}
导入mx.rpc.http.HTTPService;
导入mx.rpc.AsyncToken;
导入mx.rpc.events.FaultEvent;
导入mx.rpc.events.ResultEvent;
var服务:HTTPService=新的HTTPService;
service.useProxy=false;
service.method=“post”;
service.url=“[your php]”;
变量参数:对象={};
params.xml=“[your xml string]”;
var-token:AsyncToken=service.send(params);
var responder:mx.rpc.responder=新的mx.rpc.responder(onResult,onFault);
token.addResponder(应答器);
私有函数onResult(事件:ResultEvent):void{
跟踪(“XML已传递”,event.result);
}
私有函数onFault(事件:FaultEvent):无效{
跟踪(“XML传递失败”);
}
PHP端

$Data = simplexml_load_string($xml);
$result = $Data->children();
$totalrow = count($result);

for ($i = 0; $i < $totalrow; $i++ ){
   echo "This is the output:".$result[$i]['label'];
}
$Data=simplexml\u load\u字符串($xml);
$result=$Data->children();
$totalrow=计数($result);
对于($i=0;$i<$totalrow;$i++){
echo“这是输出:”.$result[$i]['label'];
}
请检查一些小错误。。希望能有帮助

注意:只能在Flex的调试模式下查看跟踪