+ Start a Discussion

C# Proxy Issue



I am having an issue running the basicSample_cs to demonstrate connectivity using C#.  I believe my problem is more of a C# issue, rather than Salesforce.com, but I am hoping that someone on the discussion boards has ran into this issue before and found a way to correct it.


I have setup the basicSample code and have been able to have it execute correctly, logging into my developer org_unit, when there isn’t a proxy server involved.  However, I have attempted to do the same on a network that requires a proxy server to access internet addresses, and I have been unable to achieve even a successful login.


The network I am on uses a proxy server script, so I don’t think the “auto-locating” of the proxy information is working by default in C#.   I have also tried to set the proxy server address manually using the following lines of code, but it doesn’t appear to be working.


<code snippet>


WebProxy myWebProxy = new WebProxy();

// Real address used in actual code

Uri newUri = new Uri("http://proxy_server:port_number");

myWebProxy.Address = newUri;

binding = new SforceService();

binding.Timeout = 15000;

binding.Proxy = myWebProxy;


I am unsure if there is another property I need to set? 


Any help would be greatly appreciated!



That normally works for me (although i use the WebProxy constructor that takes the URI, not that it should make a difference. When it fails, what error/exception do you get? perhaps your proxy server requires authentication info ?
I have tried to authenticate against the proxy server and it also failed...
I was able to get the Java example working with only the proxy server information, so my thought is I am incorrectly setting the syntax. 
I have also tried the "constructor" method to no avail though.
Any other thoughts?

How does it fail? what the error/exception you get ?
Just a general timeout exception...
Proxy login i did like this...see whether it helps you!!!

CredentialCache cache = new CredentialCache();
cache.Add(uri, "Basic",
new NetworkCredential(_proxyUserName, _proxyPassword));
cache.Add(uri, "Negotiate",
new NetworkCredential(_proxyUserName, _proxyPassword));
proxyObject.Credentials = cache;
binding.Proxy = proxyObject;



i found your post while looking for ways to use a proxy server to access the Salesforce API. i will appriciate it you could answer the following questions
  •     what does the term "uri" represent in the sample code
  • where are you setting your proxy host and port number