質問

I'm trying to call sharepoint webservices in C# console application. The code works fine when I use my local system's WSS as target application but don't work with another server accessible over the web. Following is my code.

Webs service = new Webs();
            service.PreAuthenticate = true;
            service.Credentials = new System.Net.NetworkCredential(login, password);
            //service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            service.Url = url + @"/_vti_bin/webs.asmx";

            XmlNode sites = null;

            try
            {
                sites = service.GetWebCollection();
            }
            catch (Exception ex)
            {
                return;
            }

Points to note: 1. It neither work with DefaultNetworkCredentials nor with my domain user credentials. 2. The webservice end point if pasted in a browser successfully list the web service methods. 3. I get 401 unauthorized error in all cases(accessing the remote server).

Am I missing something?

役に立ちましたか?

解決

Use a tool like Fiddler to capture the http traffic between console app and SharePoint. That will help debug what your problem is.

他のヒント

Did you check your App pool account? May be your application pool account does not have enough rights. Change your application pool account to an account that has full permissions on your site and try again. It should work.

I also found that this could be a known issue if you install Microsoft Windows XP Service Pack 2 (SP2) or Microsoft Windows Server 2003 Service Pack 1 (SP1). To solve this, you can follow the steps in this KB article - http://support.microsoft.com/?scid=kb;en-us;896861&x=14&y=17.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top