2015-03-02 79 views
1

我想在我的ASP.net應用程序中使用Salesforce的Enterprise WSDL服務來將數據導入/導出到salesforce。 該服務已導入我的項目作爲服務引用,我可以在我後面的代碼(C#)ASP.net登錄在salesforce中超時

Salesforce的對象,但是,當我嘗試通過應用程序登錄,我得到這個超時錯誤:

Message: The request channel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

Source: mscorlib

Type: System.TimeoutException

我的猜測是我需要爲Salesforce請求設置代理,那麼是否有人知道如何檢索?

這是我到目前爲止有:

using (enterprise.SoapClient loginClient = new enterprise.SoapClient("Soap")) 
     { 
      string sfPassword = "password"; 
      string sfUsername = "[email protected]"; 

      enterprise.LoginResult result = loginClient.login(null, sfUsername, sfPassword); 

      output.InnerHtml = "SessionID: " + result.sessionId + "<br />" + 
           "SessionURL: " + result.serverUrl; 

     } 

編輯:

https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_login.htm

發現這個網頁,其中包含的代碼片段使用代理。但問題是我沒有選擇ConnectorConfig或EnterpriseConnection。似乎這是JAVA代碼,但我需要C#示例。有任何想法嗎?

感謝, 邁克爾

回答

1

新增網絡憑據行

using enterprise = NamespaceName.WebReferenceName; 
using proxy = System.Net.WebProxy; 
using System.Net; 

protected void Page_Load(object sender, EventArgs e) 
{ 
     enterprise.SforceService sforceService = new enterprise.SforceService(); 
     proxy wp = new proxy("StringOfHost", 9999); //Host, Port 
     wp.Credentials = new NetworkCredentials("username", "password"); 
     sforceService.Proxy = wp; 
     enterprise.LoginResult loginResult = sforceService.login(sfUsername, sfPwd); 
}