我编写了一个 Httpservice 来从服务器获取数据,但是当我尝试运行该服务时,它得到了错误(#2096)。下面是我的代码:
package
{
import flash.net.URLRequestHeader;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.messaging.AbstractConsumer;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public class JSONDataLoader
{
private var httpService:HTTPService;
private var errVO:ErrVO;
[Bindable]
public var errAC:ArrayCollection = new ArrayCollection();
[Bindable]
public var errStr:String;
public function JSONDataLoader(url:String)
{
httpService = new HTTPService();
httpService.url = url;
httpService.method = "POST";
httpService.contentType = "application/json";
var headerParams:Object = new Object();
headerParams["Host"] = "192.168.11.59:3333";
headerParams["Content-Length"] = 347;
httpService.headers = headerParams;
var parameters:Object = new Object();
parameters["FromDate"] = "01-01-2013 18:30";
parameters["Location"] = "String content";
parameters["LocationId"] = 2147483647;
parameters["ReportId"] = 9223372036854775807;
parameters["ReportName"] = "String content";
parameters["Team"] = "17,22,30,1,40,53,55,69,70,73,77";
parameters["TeamId"] = 2147483647;
parameters["ToDate"] = "01-01-2013 18:30";
httpService.send(parameters);
httpService.addEventListener(ResultEvent.RESULT, resultHandler);
httpService.addEventListener(FaultEvent.FAULT, faultHandler);
}
private function resultHandler(event:ResultEvent):void
{
var rawData:String = String(event.result);
var obj:Object = JSON.parse(rawData);
Alert.show("Data: " + rawData);
}
private function faultHandler(event:FaultEvent):void
{
errStr = event.fault.faultString+" "+event.message;
Alert.show("Error!!!" + errStr);
}
}
}
我在这里做什么。我的标头或请求正文是否有问题。
请帮助我,因为我在过去 2 天一直坚持这一点。
这是完整的错误消息...
错误!!!错误#2096 (mx.messaging.messages::HTTPRequestMessage)#0 body = (Object)#1 FromDate = "01-01-2013 18:30" Location = "String content" LocationId = 2147483647 ReportId = 9223372036854776000 ReportName = "字符串内容" Team = "17,22,30,1,40,53,55,69,70,73,77" TeamId = 2147483647 ToDate = "01-01-2013 18:30" clientId = (null ) contentType = "application/json" destination = "DefaultHTTP" headers = (Object)#2 DSEndpoint = "direct_http_channel" httpHeaders = (Object)#3 Content-Length = 347 Host = "192.168.11.59:3333" messageId = "C130487E -0EBA-375E-E71D-A580EFE175EE" 方法 = "POST" recordHeaders = false 时间戳 = 0 timeToLive = 0 url = "我的 url"