我直接在webroot下创建了一个名为index.jsp的XML文件,内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<product>
<name>Product 1</name>
<description>Product 1 is good</description>
<price>5</price>
</product>
<product>
<name>Product 2</name>
<description>Product 2 is good</description>
<price>15</price>
</product>
<product>
<name>Product 2</name>
<description>Product 2 is good</description>
<price>25</price>
</product>
</catalog>
在WEB-INF / flex下的proxy-config.xml中:
<destination id="getXML">
<properties>
<url>http://localhost:8080/FlexTest/index.jsp</url>
</properties>
</destination>
在main.mxml中,httpservice如下:
<mx:HTTPService id="httpService" destination="getXML" useProxy="true" />
对应的DataGrid:
<mx:DataGrid dataProvider="{httpService.lastResult.catalog.product}" x="405" y="130" width="329" height="166"/>
但是当我点击按钮执行httpService.send()时,出现了一些错误,如下所示:
[RPC Fault faultString="Error sending request" faultCode="Server.Proxy.Request.Failed" faultDetail="Connection refused: connect"]
at mx.rpc :: AbstractInvoker / http://www.adobe.com/2006/flex/mx/internal :: faultHandler()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ rpc \ src \ MX \ RPC \ AbstractInvoker.as:290] at mx.rpc :: Responder / fault()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ rpc \ src \ mx \ rpc \ Responder.as:58] 在mx.rpc :: AsyncRequest / fault()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ rpc \ src \ mx \ rpc \ AsyncRequest.as:103] 在NetConnectionMessageResponder / statusHandler()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ rpc \ src \ mx \ messaging \ channels \ NetConnectionChannel.as:581] 在mx.messaging :: MessageResponder / status()[C:\ autobuild \ 3.5.0 \ frameworks \ projects \ rpc \ src \ mx \ messaging \ MessageResponder.as:222]
我希望有人可以帮我解决,非常感谢。
答案 0 :(得分:0)
也许你必须给你的HTTPService一个网址,比如
<mx:HTTPService id="httpService" url="http://localhost:8080/FlexTest/index.jsp" destination="getXML" useProxy="true"/>