Whilst trying out some development concepts using the SharePoint Lists.asmx web service I came across the above error message everytime I tried to call the GetList or GetListItems method. My code was simple:
Dim serLists as New myService.Lists
serLists.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim myItems as XmlNode = serLists.GetListItems("MyList", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
However whenever I ran this through I got the mysterious error:
Microsoft.SharePoint.SoapServer.SoapServerException
Visual Studio debugging did not report any inner exceptions so I could not find out what the problem was.
The solution is a simple one. The Lists web service will execute methods on the root web (SPWeb as in site) on the Site Collection, even if your web service reference is to a site further down the site collection.
There is a URL property on the proxy class generated for the web service, you need to set this to the url of the web service within your sub site. This must be set BEFORE you use the service proxy class to call the method.
Example
'Set the Url property of the service for the path to a subsite.
'Not setting this property will return the lists in the root web site.
serLists.Url = http://Server_Name/Subsite_Name/_vti_bin/Lists.asmx
Hope this helps!
No comments:
Post a Comment
Please leave a comment if you have found this post useful, or if there are any errors. I will do my best to assist if a posted solution does not help with your problem.