2014-10-28 71 views
0

我需要通過另一個Web服務並行於Web服務運行多個HTTP Web請求。需要通過另一個Web服務並行於Web服務運行多個HTTP Web請求

我已經找到了相關解決方案相關的位置: Trying to run multiple HTTP requests in parallel, but being limited by Windows (registry) Trying to run multiple HTTP requests in parallel, but being limited by Windows (registry)

我的問題是類似這樣的問題。

此前,我通過C#WinForms應用程序多次並行地從我的機器調用Web Service。 那時候,使用ServicePointManager.DefaultConnectionLimit解決了我的問題。

現在,我的要求已經改變。 還有另一個應用程序,它現在是一個只有1個網頁的Web服務,並行地由多個用戶調用。這個Web服務調用另一個Web服務,所以我們有多個並行調用離開Web服務器機器。

我是Web的noob,所以我無法弄清楚我需要在Web服務上設置ServicePointManager.DefaultConnectionLimit。 (我在我的Winforms應用程序中的Main()中執行它。)

我的問題是我在哪裏指定ServicePointManager.DefaultConnectionLimit?

該Web服務沒有一個Main(),它只有一個Global.asax,其中主要有代碼片段和管道。

/// <summary> 
    /// Required designer variable. 
    /// </summary> 
    private System.ComponentModel.IContainer components = null; 

    public Global() 
    { 
     InitializeComponent(); 
    } 

    protected void Application_Start(Object sender, EventArgs e) 
    { 
     AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 

     this.Initialise(); 
    } 

    #region Web Form Designer generated code 
    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor. 
    /// </summary> 
    private void InitializeComponent() 
    {  
     // 
     // Global 
     // 
     this.Error += new System.EventHandler(this.Global_Error); 

    } 
    #endregion 

    private void Global_Error(object sender, System.EventArgs e) 
    { 
     HandleLastError(); 
    } 


    protected void Application_Error(Object sender, EventArgs e) 
    { 
     HandleLastError(); 
    } 

    private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) 
    { 
     Exception unhandledException = (Exception)e.ExceptionObject; 
     HandleException(unhandledException); 
    } 

    private void HandleLastError() 
    { 
     Exception lastError = Server.GetLastError(); 

     HandleException(lastError); 
    } 

    private static void HandleException(Exception exception) 
    { 
     Logger logger = new Logger(typeof(CreditCheck)); 

     string lastErrorMessage = (exception == null ? "No exception" : exception.Message); 

     logger.Error(lastErrorMessage, exception); 
    } 

我的問題是我在哪裏指定ServicePointManager.DefaultConnectionLimit?

只有一個.asmx(和.asmx.cs)文件,它只包含我工作的函數。 該功能應該調用其他Web服務。 這個函數在每次Web服務命中時都會調用(在1秒內多次 - 大約10次),所以我不確定在這裏可以指定ServicePointManager.DefaultConnectionLimit,因爲這意味着在每次命中時重置它。

此外,這是託管在共享服務器上,所以我不想混亂註冊表鍵值,但我很樂意以編程方式進行此更改。

任何幫助將不勝感激。

回答

0

只是一個想法的人,我可以把它放在 protected void Application_Start(Object sender,EventArgs e){}?

還有別的東西叫Application_Start()。

有無論如何,我可以確定此WebService的起點? (從項目屬性還是WebServices中默認的東西?)

+0

所以,似乎把代碼放在Application_Start()爲我工作。 我仍然找不到任何支持默認入口點的文檔是Application_Start()。這可以從Config或Xml文件之一的應用程序屬性aor驅動嗎?或者它是Web服務的默認設置? 會很高興知道..... – 2014-10-30 10:09:44