Creating a Salesforce Session using a Proxy
1) Proxy settings can be defined in the ConnectionStrings.Config
<?xml version="1.0" encoding="utf-8"?> <connectionStrings> <add name="core" connectionString="user id=u_sc;password=x;Data Source=trinity;Database=Sitecore_Core" /> <add name="master" connectionString="user id=u_sc;password=x;Data Source=trinity;Database=Sitecore_Master" /> <add name="web" connectionString="user id=u_sc;password=x;Data Source=trinity;Database=Sitecore_Web" /> <add name="S4SConnString" connectionString="S4S:user id=s4s.api@fuseit.com; password=x; token=XoTykMKTCti9mZUZeGw0mF823; environment=Production; proxyserver=192.168.5.124; proxyport=808; proxyusername=sean; proxypassword=y"/> <add name="S4SConnStringUI" connectionString="S4S:user id=s4s.api@fuseit.com; password=x; token=XoTykMKTCti9mZUZeGw0mF823; environment=Production; proxyserver=192.168.5.124; proxyport=808; proxyusername=sean; proxypassword=y"/> </connectionStrings>
2) Proxy Setting Properties for Connection string
The following properties are exposed by the SalesforceConnectionStringBuilder Class
Description("This indicates if Proxy settings should be read from the system or not. This takes precedence over other proxy settings."), DisplayName("Proxy Auto Detect"), DefaultValue("True")] public bool ProxyUseSystem { get { if (ContainsKey(proxyUseSystemToken)) { return (bool)this[proxyUseSystemToken]; } return false; } set { this[proxyUseSystemToken] = value; } } [DisplayName("Proxy Password"), PasswordPropertyText(true), DefaultValue(""), Description("A password if authentication is to be used for the proxy.")] public string ProxyPassword { get { if (ContainsKey(proxyPasswordToken)) { return (string)this[proxyPasswordToken]; } return null; } set { this[proxyPasswordToken] = value; } } /// <summary> /// The TCP port for the proxy server (defaults to 80). /// </summary> [DefaultValue(""),Description("The TCP port for the proxy ProxyServer (default 80)."), DisplayName("Proxy Port")] public int ProxyPort { get { if(this.ContainsKey(proxyPortToken)) { int port = 80; if (int.TryParse((string)this[proxyPortToken], out port)) { return port; } else { Logging.Error(typeof(SalesforceSession), "Failed to parse Proxy Port from [" + this[proxyPortToken] + "]"); } } return 80; } set { this[proxyPortToken] = value; } } [DefaultValue(""), DisplayName("Proxy Server"), Description("If a proxy Server is given, then the HTTP request is sent to the proxy instead of the server otherwise specified.")] public string ProxyServer { get { if (ContainsKey(proxyServerToken)) { return (string)this[proxyServerToken]; } return null; } set { this[proxyServerToken] = value; } } [Description("The ssl type to use when connecting to the proxy server (default: AUTO)."), DisplayName("Proxy SSL Type"), DefaultValue("")] internal string ProxySSLType { get; set; } [DefaultValue(""), DisplayName("Proxy User"), Description("A user name, if authentication is to be used for the proxy.")] public string ProxyUser { get { if (ContainsKey(proxyUserNameToken)) { return (string)this[proxyUserNameToken]; } return null; } set { this[proxyUserNameToken] = value; } }
3) Salesforce sessions using the Proxy can be established using the connection string
public LoginDetails(string connectionString) { if (string.IsNullOrEmpty(connectionString)) { throw new System.Configuration.ConfigurationErrorsException("Null or empty connection string"); } this._connectionStringBuilder = new Data.SalesforceConnectionStringBuilder(connectionString); }