2013-01-17 249 views
0

我已經創建了一個名爲test.asmx一個我們bservice它看起來像這樣:Web服務無法正常工作在服務器端

[WebService(Namespace = "http://insforia.com/Webservices/StockTickers/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[WebMethod(Description = "Using stock symbol gets delayed stock information from Yahoo.", EnableSession = false)] 
public string[] GetQuote() 
{ 
    string username = Session["username"].ToString(); 
    string company = "BSE-100.BO+COALINDIA.BO+TCS.BO+WIPRO.BO+SBIN.NS+MNM.BO+RCOM.BO+TATASTL.BO+GMRINFRA.BO+ICICIBANK.BO"; 
    string stockcodes = "sl1c6"; 

    string url = "http://in.finance.yahoo.com/d/quotes.csv?s=" + company + "&f=" + stockcodes; 

    var webRequest = HttpWebRequest.Create(url); 
    var webResponse = webRequest.GetResponse(); 

    using (StreamReader sr = new StreamReader(webResponse.GetResponseStream())) 
    { 
     buffer = sr.ReadToEnd(); 
    } 

    var buffer = buffer.Replace("\"", ""); 
    buffer = buffer.Replace("\r\n", ","); 
    var bufferList = buffer.Split(new char[] { ',' }); 

    return bufferList; 
} 

和我打電話像這樣在我的aspx頁面此Web服務:

private string userid = "admin"; 

protected void Page_Load(object sender, EventArgs e) 
{ 
    Session["username"] = userid; 
    test oo = new test(); 
    bufferList = oo.GetQuote(); 
} 

東西是它在我的本地主機完美工作,但當我上傳到服務器上它給我一個錯誤,它找不到test

看到確切的錯誤,這是鏈接:

http://insforia.com/Webservices/StockTickers/stockmain.aspx 

我不明白該怎麼辦?爲什麼發生這種情況。我知道這是一個非常愚蠢的問題,但我從昨天開始嘗試。

+0

什麼是您的測試課程? – TheWhiteRabbit

回答

0

嘗試不使用會話。 發送用戶名的參數;

public string[] GetQuote(string UserName) 
{ 
... 
    return bufferList; 
}