Come prendere un Microsoft.SharePoint.SoapServer.SoapServerException?
-
23-10-2019 - |
Domanda
Sono un po 'perplesso su come prendere un tipo di errore specifico di Microsoft.SharePoint.SoapServer.SoapServerException, ti spiego perché, e ho incluso un esempio di codice di seguito per voi ragazzi a vedere.
Come sapete ci sono 2 modi per interagire con MOSS.
- Il modello a oggetti (funziona solo su MOSS Server)
- Web Services (può essere eseguito su un computer remoto interrogare il server MOSS)
Quindi, come per esempio di codice che sto usando i servizi web di ricerca MOSS, a causa di questo non ho SharePoint installato sul server remoto che esegue questi servizi web e senza MOSS installato la sua impossibilità di fare riferimento alla DLL SharePoint per ottenere il specifico tipo di errore: Microsoft.SharePoint.SoapServer.SoapServerException.
Se non riesco a fare riferimento la DLL allora come diavolo dovrei prendere questo tipo di errore specifico?
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)
{
}
Soluzione
La sua realtà uno System.Web.Services.Protocols.SoapException
Altri suggerimenti
Riferimento: Come arrivare FaultException dettagli ? a>
catch (FaultException fe)
{
MessageFault msgFault = fe.CreateMessageFault();
XmlElement elm = msgFault.GetDetail<XmlElement>();
var exceptionDetails = elm.InnerText;
}