Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have asked this question on stackoverflow as well but no answer.

I'm trying to call sharepoint webservices in a C# console application. The code works fine when I use my local system's WSS as target application but it doesn't work with another server accessible over the web. Here 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?

share|improve this question
    
Hi there. I haven't tested your code, but when working with Sharepoint References from a Console application, you have to set your build to 64bit (since SP2010 is 64 bit only) –  Fox Feb 9 '12 at 6:34
    
Thanks for your response but I'm trying to access MOSS 2007 webservice. –  Mujtaba Hassan Feb 9 '12 at 8:14
    
what kind of authentication is accepted by the target server ? What is the subcode of the error ? 401.1, 401.2, etc.. This can be found only in the IIS log files. –  Steve B Apr 11 '12 at 9:20

1 Answer 1

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.

UPDATED : After some exploration, I 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.

share|improve this answer
    
But if the App Pool user has no access then it should not allow to hit the URL successfully in browser. What do you think? –  Mujtaba Hassan Feb 9 '12 at 8:21
    
Please see my updates :) –  Deepu Nair Feb 10 '12 at 8:24
    
That really helped. :) –  Mujtaba Hassan Feb 10 '12 at 12:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.