Adding a web reference in Visual Studio 2010 to point to a Sharepoint 2007 site

Jesse Roper picture Jesse Roper · Mar 23, 2011 · Viewed 16k times · Source

I'm building a console application that can load a content type and remove the seal on it through C#. In attempting to add a web reference to the application, I'm getting an error which is strange because I use the same web reference in another application and it works fine. I'm pretty sure I hit this problem before and fixed it, but I cannot remember how :(

My steps:

  1. Right-click project and click Add Service Reference...
  2. Click Advanced... button
  3. Click Add Web Reference... (I receive the same error when attempting to add this as a Service Reference instead)
  4. Paste URL in text box: http://(domain)/videolibrary/_vti_bin/lists.asmx and press Enter
  5. The box on the left side shows all my service operations, but the box to give the web reference a name and the Add Reference button are grayed-out and the following error is shown above:

There was an error downloading 'http://(domain)/videolibrary/_vti_bin/lists.asmx'. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:80 Metadata contains a reference that cannot be resolved: 'http://(domain)/videolibrary/_vti_bin/lists.asmx'. There was no endpoint listening at http://(domain)/videolibrary/_vti_bin/lists.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:80 If the service is defined in the current solution, try building the solution and adding the service reference again.

EDIT: Tried changing Target Framework from .NET Framework 4 Client Profile to .NET Framework 3.5 to no avail

Answer

Łukasz picture Łukasz · Sep 11, 2012

The following solved my problem:

http://social.msdn.microsoft.com/Forums/zh/wcf/thread/02ce9fb9-6f67-45ec-9668-2dcd2317aab0

If you are behind firewall you need to make Visual Studio use the system proxy settings which can be done by manipulating your devenv.exe.config file.

Open it in Visual Studio and alter the section as below:

<system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
        <proxy usesystemdefault="True" proxyaddress="http://yourproxyserver:port" bypassonlocal="False"/>
    </defaultProxy>
    <settings>
        <servicePointManager expect100Continue="false" />
        <ipv6 enabled="true"/>
    </settings>
</system.net>