开发者

Send XML String With HTTP Post In Actionscript 3

I am having a little trouble sending an xml string to an HTTPService an Actionscript3 (see code below). Basically, I am trying to send a georss xml string for conversion into another format. I am getting an ioError and suspect the xml is causing havoc with the services parser.

I know this approach is probably not the best, but this is where I am at. I am open to any and all suggestions.

<mx:HTTPService id="testService" url="http://localhost/testservice.ashx" 
    fault="httpFaultHandler(event)"
    result="httpResultHandler(event)"
    method="POST"
</mx:HTTPService>


private var georss:XML = {A GeoR开发者_JS百科SS XML Document}     
private var georssString = georss.toXMLString();

private function testService():void
{
    testService.cancel();
    var params:Object = new Object();
    params.layer = 'TestLayer';
    params.inputdata = georss;
    testService.send();
}


Looks like it may be because you're not actually passing the params object with your service. Try this:

testService.send(params);

If that doesn't turn out to be the problem, you can get more information by enabling logging.

protected function initLogging():void {
    var t:TraceTarget = new TraceTarget();
    t.filters=['*'];
    t.level = LogEventLevel.ALL;
    t.includeDate = true;
    t.includeTime = true;
    t.includeCategory = true;
    t.includeLevel = true;

    Log.addTarget(t);
}

Just call initLogging() when your app starts up. You should see a ton of info fly by on the console now (if you run in Debug mode). Among the information will be the contents of the request that the HTTPService sends. That may contain some clues as to what is going on.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜