I had read this:
Flex: HTTP request error #2032
And this:
http://www.judahfrangipane.com/blog/2007/02/15/error-2032-stream-error/
Trying to figure out whats going on, and im failing big time so far…
I can not consume even the simplest servlet with HTTPService component, they all fail and i have no idea why.
tryed Post and Get as well.
HTTP request error
Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Error de secuencia. URL: http://localhost:8080/root/test"]. URL: http://localhost:8080/root/test
Flex:
<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:Declarations>
<s:HTTPService
id="httpSerciseTest"
url="/root/test"
method="GET"
resultFormat="e4x"
useProxy="false"
result="resultHandler(event)"
fault="Alert.show(event.fault.faultString+
'\n' + event.fault.faultDetail,
'Error: '+event.fault.faultCode)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]private var xmlResult:XML;
private function creationCompleteHandler():void
{
httpSerciseTest.send();
}
private function resultHandler(event:ResultEvent):void
{
xmlResult=event.result as XML;
}
]]>
</fx:Script>
</s:Application>
Java servlet:
public class Test extends HttpServlet {
private static final long serialVersionUID = 4484874511692568559L;
private static final String CONTENT_TYPE = "text/xml; charset=utf-8";
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException
{
response.setContentType(CONTENT_TYPE);
try{
PrintWriter writer=response.getWriter();
writer.println("<?xml version=\"1.0\"?>\n");
writer.println("<root>");
writer.println("<folder label=\"Repository\"/>");
writer.println("<folder label=\"Documentation\"/>");
writer.println("</root>");
}catch (IOException IOE){
throw IOE;
}
}
}
web.xml
<servlet>
<servlet-name>test</servlet-name>
<display-name>test</display-name>
<servlet-class>java_servlets.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
also, im using filereference uploading and downloading files with servlets and they’re working fine, but if i call the very same servlets with HTTPService, they fail too…
Edit: localhost:8080/root/test shows a HTTP Status 404 page.
2nd Edit: I copy pasted the doGet from this test example to my file upload servlet and its working, HTTPService can consume it from there, but not from the new ones i created, including this test…
OK, i got it working, two things were happening:
1.- You cant consume a servlet’s Post method without any parameters, i did change method=”POST” for method=”GET” as shown in the example, but sometimes i have a hard time with eclipse recompiling changes on my java source folder, i usually have to do a clean and restart the JBoss for eclipse to fully deploy new changes.
2.- As shaunhusain suggested, i tried the url localhost:8080/root/test expecting to see the xml but i got a 404, so the servlet wasnt even avaliable in the first place, and so far, i still cant get the Test servlet to be avaliable, but i got the one needed working, i still dont know wich part of the War is for the compiled servlets, or how to make sure they get deployed.
Imma try to figure out how the java servlets are recognized by ecplise and then deployed on my own, but if someone kindly explains the process or gives a good source, i will mark it as the correct answer, since this was the main reason of my problem.
Edit: One more thing, fault event is not getting my thrown exceptions, when something fails on the doPost or doGet function, i get a HTTP request error #2032 instead of the real error message.
Edit: Found it!, turns out eclipse randomly fails to publish full changes and some servlets never get published.
this is the only reliably way i found to get it working so far:
delete the server from the servers view,
go to
“workspace.metadata.plugins\org.eclipse.wst.server.core\publish”,
delete all your publish.xml files, then
restart eclipse.
http://www.eclipsezone.com/eclipse/forums/t88527.html
This also happens with messagebroekr/amf very frequently.