如何捕获 Microsoft.SharePoint.SoapServer.SoapServerException?

发布于 2024-09-03 18:27:35 字数 1590 浏览 2 评论 0原文

我对如何捕获 Microsoft.SharePoint.SoapServer.SoapServerException 的特定错误类型感到有点困惑,我将解释原因,并且我在下面提供了一个代码示例供大家查看。

如您所知,有 2 种方式与 MOSS 交互。

  1. 对象模型(仅在 MOSS 服务器上运行)
  2. Web 服务(可以在查询 MOSS 服务器的远程计算机上运行)

因此,根据代码示例,我使用 Web 服务来查询 MOSS,因此我没有安装共享点在运行这些 Web 服务的远程服务器上,如果未安装 MOSS,则无法引用 SharePoint DLL 来获取特定错误类型:Microsoft.SharePoint.SoapServer.SoapServerException。

如果我无法引用 DLL,那么我到底应该如何捕获这个特定的错误类型呢?

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)
            {

            }

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)
            {

            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

双马尾 2024-09-10 18:27:35

它实际上是一个 System.Web.Services.Protocols.SoapException

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

复古式 2024-09-10 18:27:35

参考:如何获取FaultException详细信息?

catch (FaultException fe)
    {
         MessageFault msgFault = fe.CreateMessageFault();
         XmlElement elm = msgFault.GetDetail<XmlElement>();
         var exceptionDetails = elm.InnerText;
    }

Reference: How to get FaultException details?

catch (FaultException fe)
    {
         MessageFault msgFault = fe.CreateMessageFault();
         XmlElement elm = msgFault.GetDetail<XmlElement>();
         var exceptionDetails = elm.InnerText;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文