0

HttpService を拡張する xxHttpService という名前のクラスを作成し、ローカル サーバーに送信して処理を実行するためにカスタム ヘッダーを設定するコンストラクト メソッドをオーバーライドします。奇妙なことに、ヘッダーから値を取得できません。常に A です。サーバー側からBとして設定したので。洞察を得ましたか?前もって感謝します 。

public class xxxHttpService extends HTTPService
    {
        public function xxxHttpService( handler:Function ){

            ****
            this.headers = {HTTP_USER: "Wking"};
            ****
              }
        }
4

1 に答える 1

0

mxml バージョンを使用していない場合、mx.rpc.http.HTTPService のコンストラクターには次の見出しがあります。

HTTPService(rootURL:String = null, destination:String = null)

パッケージ mx.rpc.http.mxml.HTTPService にある mxml バージョンを使用している場合、引数を持つコンストラクターを持つことはできません。

最初のケースについて話していると思います。

そのコンストラクターをオーバーライドすると、クラス定義が得られます。

public class XxxHttpService extends HTTPService
{
   public function XxxHttpService(rootURL:String = null, destination:String = null) {
      super(rootURL, destination);
      ...
      this.headers = {HTTP_USER: "Wking", HTTP_PASSWORD: "Equeen"};

   }

}

本サービスの構築

myService = new XxxHttpService("http://rooturl" , "myDestination")
myService.addEventListener(myHandler, ResultEvent.RESULT)
...
protected function myHandler(event:ResultEvent) {
   ...
}

あなたに与えるべきです:

HTTP_USER:Wking
HTTP_PASSWORD:Equeen

関数 send() を呼び出すときの http ヘッダー

myService.send();

よくわかりませんが、それらを GET 変数の POST として送信したい場合は、次のようにする必要があります。

myService.method = "POST";//or "GET"
myService.send({HTTP_USER: "Wking", HTTP_PASSWORD: "Equeen"});
于 2012-09-30T06:34:28.857 に答える