1

I am trying to get data from a SharePoint list by using SharePoint Lists Web service. I have a MS Office Excel Add-In with a WPF User Control inside it. I used the following code to make a proxy object to the Lists Web Service. And use that proxy to obtain list 'Products'.

        1. SPListWS.Lists myListReadProxy = new SPListWS.Lists();
        2. myListReadProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
        3. myListReadProxy.Url = "http://sp2010:4321/_vti_bin/Lists.asmx";
        4. 
        5. XmlNode myNode = myListReadProxy.GetList("Products");

Visual Studio come up with an error at the line 5, saying that

The request failed with HTTP status 401: Unauthorized.

I changed the code as following to provide credentials explicitly. But the same error arises. myListReadProxy.Credentials = new NetworkCredential("myusername", "mypassword");

And I checked the permission for the web service and the List. I have full permission. When I handle the Web Exception is gives the status as 'Protocol Error'.

Can you please help me with this?

0

I finally figured out what was wrong with my project. Actually when I add a web reference for my project, I clicked on Add Service Reference and searched for services in my local machine. So I found my Lists web service with url like this http://localhost:4321/_vti_bin/Lists.asmx instead of http://sp2010:4321/_vti_bin/Lists.asmx . And when I set the URL for my proxy object I added the url as http://sp2010:4321/_vti_bin/Lists.asmx in the code section.

When I change my web reference to use the explicit server name everything worked fine. Hope somebody would find this helpful if they faced to a similar situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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