web-services - Sharepoint 2007 AddList 和 AddListFromFeature 缺少模板列和数据内容

标签 web-services sharepoint sharepoint-2007 moss

我做了什么

  • 在 SharePoint 内部,我基于项目任务模板创建了一个列表
  • 我删除了大多数默认列,并添加了新的自定义列
  • 我使用新格式添加了数据
  • 然后我做了一个“另存为模板”并选择保存内容为
  • 的模板。

    什么工作

    现在,当我使用该模板在 SharePoint 内创建一个新列表时,它可以完美运行。存在自定义列,并且数据全部按预期预填充。

    什么不起作用

    但是,当我使用 AddList 时或 AddListFromFeature SharePoint Web 服务提供的方法创建新列表,但它只是基于原始项目任务模板和 。默认列 没有数据 !

    我试过的
  • 我尝试按照建议 in the article from Phase 2设置自定义模板 ID,但这只会阻止我使用该模板(在我执行“创建”时不再列出)。
  • 我仍在试图弄清楚是否 this article applies - 这似乎是一个类似的问题,但适用于站点而不是列表。
  • 我发现另一个人是having the same problem大约一年前。

  • 系统设置

    使用 SharePoint 2007(我认为?),使用 PHP 和 NuSOAP 进行连接。由于我已将项目添加到列表、创建列表和读取数据,因此连接肯定有效。

    代码示例

    请求 - 针对上面的第 2 阶段方法模板
    <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2034="http://tempuri.org"><SOAP-ENV:Body>
    <AddListFromFeature xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <listName>2Test Milestone Release</listName>
        <description>Testing this out</description>
        <featureID>{00BFEA71-513D-4CA0-96C2-6A47775C0119}</featureID>
        <templateID>151</templateID>
    </AddListFromFeature></SOAP-ENV:Body></SOAP-ENV:Envelope>
    

    响应 - 由于无法识别 templateID 而失败
    <?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><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Cannot complete this action.
    
    Please try again.</errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x81072101</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>
    

    我难住了!所以,如果你能帮上忙——我会是一个非常快乐的人!提前致谢!

    最佳答案

    我会追问为什么你不能首先通过界面创建列表,这两个 Web 服务调用似乎不包含从自定义模板创建时的重要参数,让我们分析查询字符串:

    新项目任务(开箱即用)

    http://site/_layouts/new.aspx?FeatureId= {00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate=150

    新建项目任务自定义(保存在列表模板库中)

    http://site/_layouts/new.aspx ? 自定义模板=PT6.stp &FeatureId={00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate=150

    新项目任务自定义(manifest.xml 编辑为 151)

    http://site/_layouts/new.aspx ? 自定义模板=PT6.stp &FeatureId={00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate= 151

    它们都可以工作,所以我的看法是 Web 服务不适合自定义模板,或者它有一些 secret 魔法(在列表定义中很常见),因为仅指定 ListTemplate 而不明确 CUSTOM 即使在 UI 中也不起作用.

    如果您无法解决这个明显的限制,我的建议是:

  • .NET,请注意 this post如果你碰巧遇到同样的错误
  • 在第一条评论中有一些伏都教
  • 使用 http://site/_layouts/new.aspx 制作 IFRAME ? 自定义模板=PT6.stp &FeatureId={00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate=150 作为源代码并使用javascript填充字段,然后触发OK按钮点击,进行一些完整的页面加载转换,它甚至会看起来不错。

  • 方法 2 需要在同一个域中完成,如果您不是在同一个域中运行 PHP(不太可能),则需要在 SharePoint 站点内创建一个页面来包含此 hack,它可以像 Web 部件页面一样简单使用内容编辑器 Web 部件,您可以读取一些查询字符串参数,将它们放在字段上,触发 OK 并等待页面更改,以便您可以重定向到“成功”页面。

    编辑:我很好奇并查看了 New.aspx 的源代码,它有这个小片段 (bIsCustomTemplate = strCustomTemplate != null, strCustomTemplate = querystring "CustomTemplate"):
    <% if (bIsCustomTemplate) { %>
    <input id="onetidCustomTemplate" type="Hidden" name="CustomTemplate" value=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(strCustomTemplate),Response.Output);%> />
    <% } %>
    

    我看了下反汇编的代码,但我认为我们不能把它贴在这里,但它只能证明UI从一个帖子(Request.Form)构建它并寻找CustomTemplate参数,而Web Service只有这些方法如果您不能指定自定义模板。

    关于web-services - Sharepoint 2007 AddList 和 AddListFromFeature 缺少模板列和数据内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1139374/

    相关文章:

    web-services - wince 6智能设备无法建立SSL/TLS安全通道错误

    sharepoint - 爬虫不创建自定义爬网属性

    c# - 获取 SPFieldCurrency 字段的数值

    javascript - 如何使用 javascript 创建 soap 消息进行文件上传?

    python - 我如何在 python 中使用 wsdl url

    wcf - 使 WCF 4 WSDL 看起来像 Web 服务 WSDL?

    c# - 接收错误 "The type or namespace name ' LayoutsPageBase' 找不到”

    sharepoint - 在 SharePoint 中保留本地配置数据

    sharepoint-2007 - SharePoint 权限 : User with Contribute change cannot change a list item they did not create?

    sharepoint - 新升级的 InfoPath 字段不在表单库中?