我在Java中創建一個servlet,它會給我一個XML響應稱爲獲取XML中的Flex
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml; charset=utf-8"); // Set the servlet's response type to XML.
PrintWriter out = null;
try {
out = response.getWriter();
XMLOutputFactory of = XMLOutputFactory.newInstance();
XMLStreamWriter writer = of.createXMLStreamWriter(out);
writer.writeStartDocument();
writer.writeStartElement("Test");
for(int i = 1; i <= 100; i++) {
writer.writeStartElement("TheNumber");
writer.writeAttribute("number", "" + i);
writer.writeAttribute("value", "" + Math.pow(2, i));
writer.writeEndElement();
}
writer.writeEndElement();
writer.close();
out.close();
} catch (Exception ex) {
}
}
現在我想在Flex中得到這個XML時,有人可以給我一個提示?我試過mx:WebService和mx:HttpService,但他們都沒有工作。
在此先感謝
塞巴斯蒂安
使用剛剛得到了解決HttpService的......現在我要找出原因 – 2009-06-03 14:40:47