以下是.mxml
代码,应该运行在URL http://localhost:8084/HelloWorld/index.jsp:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:maps="com.google.maps.*"
viewSourceURL="srcview/index.html">
<mx:HTTPService id="srv" url="http://localhost:8084/HelloWorld/index.jsp" />
<mx:Button label="Get Data" click="srv.send()"/>
<mx:Button label="Print" click="creationCompleteHandler(event)"/>
<mx:Script>
<![CDATA[
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.TextArea;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.utils.ObjectUtil;
import mx.utils.XMLUtil;
protected function creationCompleteHandler(event:Event):void
{
//http://localhost:8084/GetShapeFiles/
Alert.show("Here comes data: ");
}
]]>
</mx:Script>
</mx:Application>
当我在浏览器上打开URL时,它正在打开但无法通过.mxml
运行。出现错误:
[RPC Fault faultString="Error #1096: XML parser failure: Unterminated element." faultCode="Client.CouldNotDecode" faultDetail="null"]
at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpchttpHTTPService.as:851]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAbstractInvoker.as:188]
at mx.rpc::Responder/result()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcResponder.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:autobuild3.2.0frameworksprojectsrpcsrcmxmessagingchannelsDirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
我认为这个错误是不言自明的。返回的XML无法解析,可能是因为没有正确格式化。可能是您的jsp没有发送好的xml,或者您的服务器不理解jsp,只是将其作为纯文本返回给Flex。
我也没有看到你是如何使用这个xml。因为我只看到一个"获取数据"和一个"打印"按钮,从来没有涉及到返回的结果。