在 Actionscript 3 中使用 HTTP Post 发送 XML 字符串

发布于 2024-08-18 10:46:05 字数 699 浏览 4 评论 0原文

我在将 xml 字符串发送到 HTTPService 和 Actionscript3 时遇到了一些麻烦(请参阅下面的代码)。基本上,我正在尝试发送 georss xml 字符串以转换为另一种格式。我收到 ioError 并怀疑 xml 对服务解析器造成严重破坏。

我知道这种方法可能不是最好的,但这就是我的处境。我对任何建议持开放态度。

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


private var georss:XML = {A GeoRSS 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();
}

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 GeoRSS 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();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光暖心i 2024-08-25 10:46:05

看起来可能是因为您实际上并未通过服务传递 params 对象。试试这个:

testService.send(params);

如果这不是问题,您可以通过启用日志记录来获取更多信息。

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);
}

只需在应用程序启动时调用 initLogging() 即可。您现在应该会在控制台上看到大量信息(如果您在调试模式下运行)。这些信息包括 HTTPService 发送的请求的内容。这可能包含一些关于正在发生的事情的线索。

希望有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文