Wednesday, May 20, 2009

Getting a SoapServerException after installing MOSS 2007 Service Pack 2

It appears that Service Pack 2 for MOSS 2007 has made some changes to the SharePoint Web Services in the way that it handles errors.

Today we noticed that the following error was being thrown from one of the List
ServicesException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
Before the Service pack was installed the exception was encapsulated within the XML returned by the method. After installing Service Pack 2 the method throws the exception and it must be caught by a try and catch statement.

This is how we used to handle the error

Service.Lists listsProxy = new Service.Lists();
listsProxy.Credentials = new NetworkCredential(sUser, sPassword, sDomain);
XmlNode ndReturn = listsProxy.UpdateListItems("ListName", xmlQuery);
if (ndReturn.InnerText.Contains("0x81020089")) {
return false;
}
return true

after applying the Service Pack, the code needed to be changed to

Service.Lists listsProxy = new Service.Lists();
listsProxy.Credentials = new NetworkCredential(sUser, sPassword, sDomain);
try {
XmlNode ndReturn = listsProxy.UpdateListItems("ListName", xmlQuery);
catch(Exception ex){
// do something
}
return true

Hope this helps

No comments:

Post a Comment