无法在HTTPServiceWrapper(actionscript 3)中设置RequestHeader

无法在HTTPServiceWrapper(actionscript 3)中设置RequestHeader,actionscript,httprequest,Actionscript,Httprequest,我使用FlashBuilder4中以数据为中心的开发功能创建了一个HTTPService。由于某些原因,我无法为HTTP GET请求设置RequestHeader。我已尝试为mx.rpc.http.com操作设置headers对象;但是,它似乎不起作用。数据包嗅探器显示requestheader没有更改 例如,下面是gettour服务的一部分: public class GetTourService extends _Super_GetTourService { /**

我使用FlashBuilder4中以数据为中心的开发功能创建了一个HTTPService。由于某些原因,我无法为HTTP GET请求设置RequestHeader。我已尝试为mx.rpc.http.com操作设置headers对象;但是,它似乎不起作用。数据包嗅探器显示requestheader没有更改

例如,下面是gettour服务的一部分:

 public class GetTourService extends _Super_GetTourService
  {
     /**
     * Override super.init() to provide any initialization customization if needed.
     */
    protected override function preInitializeService():void
    {
      super.preInitializeService();
      // Initialization customization goes here

      var header:URLRequestHeader = new URLRequestHeader( "Accept", "application/json");
      var headers:Array = new Array();
      headers.push(header);

      var o:Object = this._serviceControl.getOperation( "gettour");
      var operation:Operation = o as Operation;
      operation.headers = headers;
    }
}
但是,数据包嗅探器将Accept标头显示为“Accept://\r\n”。在AIR中,我遇到了一个类似的问题,默认接受值列表很长,无法将接受值设置为“application/json”。我错过了什么

非常感谢您的帮助。谢谢

编辑:我今天早上找到了答案。而不是

标题。推送(标题)

我曾经

标题[“接受”]=“/application/json”

这起作用了。

因为这有点模糊,所以我想猜测一下。根据文档,
headers
是自定义头的对象,因此向其传递索引数组可能不起作用。请尝试传递已定义的对象:

operation.headers = {Accept:"application/json"};
因为这有点模糊,所以我要猜一猜。根据文档,
headers
是自定义头的对象,因此向其传递索引数组可能不起作用。请尝试传递已定义的对象:

operation.headers = {Accept:"application/json"};

在我的例子中,我有
operation=newmx.rpc.http.operation(null,“xxx”)
operation.headers={Accept:“application/json”}
,但它不起作用,知道吗?我正在使用FlashBuilder4.5中的数据网格,在我的例子中,我有
operation=newmx.rpc.http.operation(null,“xxx”)
operation.headers={Accept:“application/json”}
,但它不起作用,知道吗?我正在使用FlashBuilder4.5中的数据网格