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 =newSPListWS.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?