2015-03-02 44 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); 
}