If you need to access the Salesforce SOAP API through a proxy server using a .NET Service Reference, you may be confused about how to do this exactly. This would be needed if your .NET application needed to access Salesforce through a firewall. Unfortunately, there is precious little info out there on the Internet (especially when it comes to accessing Salesforce specifically) about how to do this precise thing, hence why I am writing this post.
When adding a web reference (which by the way is considered outdated) you would accomplish this by creating a new WebProxy object, setting the host and port for this object, along with any network credentials that might be needed and then assigning this object to the services Proxy class. This is considered such an outdated method by Microsoft, that MSDN has retired the content that references how to do it.
Microsoft prefers that you use a Service Reference when accessing web services, yet the code to do this is not so easily found. Turns out the solution is pretty simple. Service References allow you to do more advanced configuration through the more easily accessed web.config or app.config files.
BTW, If you want to learn more about the differences between service and web references, check out my DeveloperForce article on this very subject.
The simplest way to configure your application is to add something like the following to your web.config or app.config file:
<proxy usesystemdefault=”True” proxyaddress=”http:\\Proxy IP Address:Proxy Port”/>
You just need to replace the Proxy IP Address and Proxy Port placeholders with whatever values apply.
Hope this helps someone avoid a lot of wasted time searching the Internet.