我很难实现 Web 服务客户端。我正在使用 Web 引用查询 SharePoint 2010 Web 服务。下面的代码在 try 块内的行上引发异常。
SoapService.Lists service = new SoapService.Lists();
service.Credentials = CredentialCache.DefaultCredentials;
XmlDocument doc = new XmlDocument();
XmlNode query = doc.CreateNode(XmlNodeType.Element,"Query","");
XmlNode viewFields = doc.CreateNode(XmlNodeType.Element,"ViewFields","");
XmlNode queryOptions = doc.CreateNode(XmlNodeType.Element,"QueryOptions","");
query.InnerXml = @"<Where><IsNotNull><FieldRef Name='Vendor Name'/></IsNotNull></Where>";
viewFields.InnerXml = @"<FieldRef Name='Vendor Name'/>";
queryOptions.InnerXml = @"<QueryOptions/>";
try
{
XmlNode response = service.GetListItems("DLA-Suppliers", null, query, viewFields, null, queryOptions, null); // exception thrown
}
catch (System.Web.Services.Protocols.SoapException e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.Detail);
Console.WriteLine(e.StackTrace);
}
这是异常 (SoapServerException) 堆栈跟踪:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at DLAUpdateSP.SoapService.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID) in c:\users\user\documents\visual studio 2010\Projects\DLAUpdateSP\Web References\SoapService\Reference.cs:line 455
at DLAUpdateSP.Program.UpdateSuppliers(String fileLocation) in C:\Users\user\Documents\Visual Studio 2010\Projects\DLAUpdateSP\Program.cs:line 58
有人对此有任何想法吗?除了堆栈跟踪,异常的属性几乎都是空的。我以前从未做过 SOAP,所以这对我来说真的很新鲜。非常感谢任何帮助。