SharePoint 列表数据作为 XML 字符串

发布于 2024-12-05 09:17:36 字数 299 浏览 1 评论 0原文

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

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

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

谢谢杰森

I am trying to use the GetListItems web service method to retrieve all the items of a list. The method is raising an InvalidOperation exception with the message being "There is an error in XML document". It seems that at least one of the column values contains "illegal" hex values...at least as far as XML Nodes go.

Besides pulling back each item one at a time (and skipping the "bad" item), is there a way to get at the raw XML data returned by GetListItems? My thought is that if I have the raw string I can try to sanitize it before converting it to XML Nodes (and then later into a DataTable).

Any other ideas would be appreciated.

Thanks

Jason

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

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

发布评论

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

评论(2

萌吟 2024-12-12 09:17:36

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

Can you validate that the data being returned is actually the correct XML data and not an HTML error page such as a 401 or 404 error page?

顾挽 2024-12-12 09:17:36

@Jason我无法完全按照您所描述的方式重现问题,但我想尝试这种技术:

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

    1. 放置一个断点(和一个观察点),甚至更改自动生成的代码;
      在这里您可以检查(快速观看,或您最喜欢的技术)调用返回的 objec[] 结果
      即:

      [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/肥皂/”,ResponseNamespace =“http://schemas.microsoft.com/sharepoint/soap/”, Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
      公共System.Xml.XmlNode GetListItems(字符串listName,字符串viewName,System.Xml.XmlNode查询,System.Xml.XmlNode viewFields,字符串rowLimit,System.Xml.XmlNode queryOptions,字符串webID){
      object[] results = this.Invoke("GetListItems", new object[] {
                  列表名称,
                  视图名称,
                  询问,
                  视场,
                  行限制,
                  查询选项,
                  网络ID});
      
      调试.WriteLine(结果.长度);
      
      return ((System.Xml.XmlNode)(结果[0]));
      

      }

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

@Jason I could not reproduce the problem exactly as you described but I would like to try this technique:

  1. Check in your VisualStudio , Option, Debugging, General, unchek the option "Enable Just My Code"
  2. Reveal your autogenerate Reference.cs , position the cursor where you call the GetListItems ( i.e XmlNode ndListItems =
    listService.GetListItems(sList, null, ndQuery, ndViewFields, "0" , ndQueryOptions, null);
    and then pres F12 ( Go To Definition)

    1. Put a breakpoint (and a watchpoint) or even change the code autogenerated;
      here you could be able to inspect (quick watch, or your favorite tecnique) the objec[] restults returned by the invocation
      i.e:

      [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]));
      

      }

I look forward to know if this can help you better identify or solve the problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文