开发者

Error while accessing list with SharePoint WebService

I am trying to access the SharePoint List with web service and I need to update the same v开发者_运维技巧ia web service accordingly. Following is the sample code that I am using

        Lists Testlist = new Lists();

        Testlist.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; 

        Testlist.PreAuthenticate = true;

        XmlNode myNode = Testlist.GetList("sample list");  
        .
        .
        .  

However I am getting Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' when I try to use Testlist.getList() Method of web service.

I have goggled for it a lot but still not getting proper solution for the same.

Can any one help me out to solve this issue... :(


It looks like you've set up your web service proxy by adding a WCF service reference; I have tried this route before and have not had success. In fact, I bet we even get the same error; mine was a problem authenticating to the service.

Once I regenerated my proxy using the non-WCF method (adding a Web Reference), I was able to get everything working with no problems.

You do this by adding a Service Reference to your project the same way you did before, except on the "Add Service Reference" dialog, click the "Advanced..." button. This opens the "Service Reference Settings" dialog.

Here, click the "Add Web Reference..." button at the bottom, then point to your Lists service and generate your proxy classes.

In code, after you instantiate your Lists service object, use the following for authentication:

TestList.UseDefaultCredentials = true;

Now you should be able to call your methods without exceptions. If you ever stumble across a proper way to authenticate to SharePoint web services using a Visual Studio Service Reference, I'd love to hear about it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜