views:

301

answers:

1

I am a bit perplexed on how to catch a specific error type of Microsoft.SharePoint.SoapServer.SoapServerException, I'll explain why, and I've included a code sample below for you guys to see.

As you know there are 2 ways to interact with MOSS.

  1. The object model (only runs on MOSS Server)
  2. Web Services (can be run on a remote machine querying the MOSS server)

So as per code sample I'm using web services to query MOSS, because of this I don't have sharepoint installed on the remote server running these web services and without MOSS installed its impossible to reference the SharePoint DLL to get the specific error type : Microsoft.SharePoint.SoapServer.SoapServerException.

If I can't reference the DLL then how the heck am I supposed to catch this specific error type?

System.Xml.XmlNode ndListView = wsLists.GetListAndView(ListName, "");
            string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
            string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
            batchElement.SetAttribute("OnError", "Continue");
            batchElement.SetAttribute("ListVersion", "1");
            batchElement.SetAttribute("ViewName", strViewID);

            batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field>" +
            "<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>" + id + "</Value></Eq></Where></Method>";

            try
            {
                wsLists.UpdateListItems(strListID, batchElement);
                return true;
            }
            catch (Microsoft.SharePoint.SoapServer.SoapServerException ex)
            {

            }
A: 

Its actually a System.Web.Services.Protocols.SoapException

JL
Not in this case... VS Actually mentions the exception specifically as Microsoft.SharePoint.SoapServer.SoapServerException. I believe this dll is in the common files directory on the SP servers
Craig Huber
It can be caught as a System.Web.Services.Protocols.SoapException. You can't reference that DLL legally if you're calling a SharePoint Web Service from a remote machine. So it makes no sense trying to reference it, in the same way you can't use the object model from a remote machine, hence the reason for web services, hence the reason for my confusion in the first place.
JL