I'm having a difficult time implementing a web service client. I'm querying a SharePoint 2010 web service using a web reference. The code below throws an exception on the line within the try block.
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);
}
Here is the exception (SoapServerException) stack trace:
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
Does anyone have any ideas on this? Aside from the stack trace, the exception's properties were almost all null. I've never done SOAP before so this is really new to me. Any help is really appreciated.