SharePoint列表数据作为XML字符串

时间:2011-09-17 18:46:31

标签: xml web-services sharepoint-2007 wss

我正在尝试使用GetListItems Web服务方法来检索列表的所有项目。该方法引发InvalidOperation异常,消息为“XML文档中存在错误”。似乎至少有一个列值包含“非法”十六进制值......至少就XML节点而言。

除了一次退回一个项目(并跳过“坏”项)之外,还有办法获取GetListItems返回的原始XML数据吗?我的想法是,如果我有原始字符串,我可以尝试在将其转换为XML节点之前对其进行清理(然后再将其转换为DataTable)。

任何其他想法将不胜感激。

由于

杰森

2 个答案:

答案 0 :(得分:0)

您能否验证返回的数据实际上是正确的XML数据而不是HTML错误页面,例如401或404错误页面?

答案 1 :(得分:0)

@Jason我无法像你描述的那样完全重现这个问题,但我想试试这个技术:

  1. 检入VisualStudio,选项,调试,常规,取消选中“启用我的代码”选项
  2. 显示自动生成Reference.cs,将光标定位在调用GetListItems的位置(即XmlNode ndListItems =                 listService.GetListItems(sList,null,ndQuery,ndViewFields,“0”,ndQueryOptions,null);                 然后按F12(转到定义)

    1. 设置断点(和观察点)甚至更改自动生成的代码; 在这里你可以检查(快速观察,或你最喜欢的tecnique)调用返回的objec [] restults 即:

      [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
      public System.Xml.XmlNode GetListItems(string listName, string viewName, System.Xml.XmlNode query, System.Xml.XmlNode viewFields, string rowLimit, System.Xml.XmlNode queryOptions, string webID) {
      object[] results = this.Invoke("GetListItems", new object[] {
                  listName,
                  viewName,
                  query,
                  viewFields,
                  rowLimit,
                  queryOptions,
                  webID});
      
      Debug.WriteLine(results.Length);
      
      return ((System.Xml.XmlNode)(results[0]));
      

      }

  3. 我期待知道这是否可以帮助您更好地识别或解决问题