xml will not parse correctly in ASP when sent from flex
i'm sending some xml to asp from flex using the httpservice but when I try to parse the xml using the standard Microsoft.XMLDOM it always fails to parse the xml regardless of what xml I send. This leads me to think that flex is sending the xml incorrectly.
flex code>
request = new HTTPService();
request.url="http://127.0.0.1/test.asp";
request.contentType="application/xml"
request.method="POST"
request.resultFormat="text"
request.request = XML(<test>testingxml</test>);
request.addEventListener(ResultEvent.RESULT, success);
request.addEventListener(FaultEvent.FAULT, fault);
request.send();
private function success(e:mx.rpc.events.ResultEvent):void {
trace(e.result);
}
private function fault(e:mx.rpc.events.FaultEvent):void {
trace(e.message);
}
my ASP code>
Dim mydoc
Set mydoc=Server.CreateObject("Microsoft.XMLDOM")
mydoc.async=false
mydoc.load(Request)
Response.ContentType = "text/xml"
if mydoc.parseError.errorcode<>0 then
Response.write "<prob name='fail'>blah</prob>"
else
Response.write "<prob name='works'>yay</prob>"
end if
The asp script always sends <prob name='fail'>blah</prob> back to flex meaning that the xml failed to parse correctly. The xml is correct, if I load the same xml from a text file it will parse correctly, it only fails when the xml is loaded from flex.
Does anyone know the exact format that the xml is sent in using the httpservice.send() method? I tried using Request.Form in ASP but it only gives the error printed at the bottom of this post.
BTW is there anyway to get flex to trace error messages given from ASP when a script fails as I can't read them in a browser (because the request is sent using POST). When ASP gives an error flex either does not respond or gives this error which does not help my cause.
(mx.messaging.messages::ErrorMessage)#0
body = (Object)#1
clientId = "DirectHTTPChannel0"
correlationId = "39CFBD08-1AEC-89B8-EECA-57F7BC922158"
destination = ""
extendedData = (null)
faultCode = "Server.Error.Request"
faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://127.0.0.1/test.asp"]. URL: http://127.0.0.1/test.asp"
faultString = "HTTP request error"
headers = (Object)#2
messageId = "3AC23FB2-BFB0-AC27-AE06-57F7BCC14B44"
rootCause = (flash.events::IOErrorEvent)#3
bubbles = false
cancelable = false
currentTarget = (flash.net::URLLoader)#4
bytesLoaded = 0
bytesTotal = 0
data = (null)
dataFormat = "text"
eventPhase = 2
target = (flash.net::URLLoader)#4
text = "Error #2032: Stream Error. URL: http://127.0.0.1/test.asp"
type = "ioError"
timestamp = 0
timeToLive = 0
Thanks in advance
EDIT:
I wrote the value of the ASP request (sent from flex) to a text file and I ended up getting blank, in other words no XML. Now i'm not even sure if flex is sending any xml.
Last edited by Daedalus; 05-04-2007 at 05:28 PM.
|