2012-09-29 84 views
0

我創建一個擴展HttpService的一類名爲xxHttpService,我重寫構造方法中,我爲了設置自定義標題發送到本地服務器做things.Strangely,我不能讓從價值頭,它總是A,因爲我從服務器端將它設置爲B.有什麼見解?提前致謝 。如果您使用的MXML版本,這是在關於Flex HTTPService組件問題

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

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

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

如果我明白了,你設置自定義標題爲一個值在HTTPService類;但服務器總是在同一個頭中看到不同的值? – JeffryHouser

+0

你打在你的基類的構造函數? (super() - 我認爲..) – ethrbunny

回答

0

一個mx.rpc.http.HTTPService的構造函數,如果沒有你真是使用MXML版本有這個標題包mx.rpc.http.mxml.HTTPService你不能有一個帶參數的構造函數。

我想你是在談論第一個案例。

重寫該構造函數會給你的類定義:

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 
在HTTP頭

()

myService.send(); 

我不知道,但如果你要想讓他們送的GET的POST變量,你應該這樣做:

myService.method = "POST";//or "GET" 
myService.send({HTTP_USER: "Wking", HTTP_PASSWORD: "Equeen"});