I am trying to call sharepoint web services in a C # console application. The code works fine when I use the local WSS system as the target application, but I donβt work with another server accessible via the Internet. Below is my code.
Webs service = new Webs();
service.PreAuthenticate = true;
service.Credentials = new System.Net.NetworkCredential(login, password);
service.Url = url + @"/_vti_bin/webs.asmx";
XmlNode sites = null;
try
{
sites = service.GetWebCollection();
}
catch (Exception ex)
{
return;
}
Note: 1. It does not work with DefaultNetworkCredentials, nor with my domain user credentials. 2. The endpoint of the webservice, if you successfully insert the list of web service methods into the browser. 3. In all cases, I get a 401 unauthorized error (access to a remote server).
Did I miss something?
source
share