如何从UpdateListItems SOAP响应中获取错误详细信息?

时间:2013-04-16 16:27:40

标签: sharepoint soap

我正在为Microsoft SharePoint编写iOS客户端。我的目标是更新列表项的日期时间字段并获取有关错误的详细信息。我有一个带有自定义服务器端验证的日期时间字段。

这是对/_vti_bin/Lists.asmx的请求:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>{405FFE91-946E-4B2F-861E-DDB24F1629F2}</listName>
      <updates>
        <Batch OnError="Continue" ListVersion="1">
          <Method ID="1" Cmd="Update">
            <Field Name="ID">1</Field>
            <Field Name="DateTime_x0020_E">2000-08-08 07:00:00 +0000</Field>
          </Method>
        </Batch>
      </updates>
    </UpdateListItems>
  </soap:Body>
</soap:Envelope>

以下是回复:

?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <UpdateListItemsResponse 
            xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <UpdateListItemsResult>
                <Results>
                    <Result ID="1,Update">
                        <ErrorCode>0x8102001c</ErrorCode>
                        <ErrorText>Invalid date/time value.

A date/time field contains invalid data. Please check the value and try again.</ErrorText>
                        <z:row ows_ContentTypeId="0x0100D3AA6E2413CF1645A9101D3421B797AE" ows_Title="test of time" ows_DateTi... skipped...

此回复未说明此字段的有效范围。但是,当我尝试在SharePoint网站上设置无效日期时,我收到了正确的错误:

SharePoint provides details on error

问:如何使用SharePoint SOAP服务获取有关错误的详细信息?

1 个答案:

答案 0 :(得分:1)

我发现我的错误在哪里。该字段仅限日期,因此SharePoint可能不接受2000-08-08 07:00:00 +0000的值。当我只发送日期时:

<Field Name="DateTime_x0020_E">1995-08-08</Field>

我收到了正确的错误文字:

<Result ID="1,Update">
   <ErrorCode>0x810200c5</ErrorCode>
   <ErrorText>[DateTime E] - [Date should be after July 1, 2007]</ErrorText>
   ...
</Result>