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

Jos*_*hua 5 sharepoint moss web-services sharepoint-2007

我做了什么

  • 在SharePoint内部,我基于Project Tasks模板创建了一个List
  • 我删除了大多数默认列,并添加了新的自定义列
  • 我使用新格式添加了数据
  • 然后我做了"另存为模板",并选择使用内容保存模板

什么是工作

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

什么不工作

但是,当我使用SharePoint Web服务提供的AddListAddListFromFeature方法时,会创建新列表,但它只是基于原始Project Tasks模板,具有默认列没有数据!

我试过的

系统设置

使用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>
Run Code Online (Sandbox Code Playgroud)

响应 - 由于未识别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>
Run Code Online (Sandbox Code Playgroud)

我很难过!所以,如果你能提供帮助 - 我将是一个非常快乐的人!提前致谢!

Fra*_*ino 1

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

新项目任务(开箱即用)

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

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

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

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

http://site/_layouts/new.aspxCustomTemplate=PT6.stp &FeatureId={00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate= 151

它们都可以工作,所以我的看法是 Web 服务对于自定义模板来说是不行的,或者它有一些秘密魔法(在列表定义中常见),因为仅指定 ListTemplate 而不明确自定义即使在 UI 中也无法工作。

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

  1. .NET,如果您碰巧遇到相同的错误,请注意这篇文章的第一条评论中有一些巫术
  2. 使用http://site/_layouts/new.aspx制作 IFRAME ?CustomTemplate=PT6.stp &FeatureId={00bfea71-513d-4ca0-96c2-6a47775c0119}&ListTemplate=150 作为源并使用 javascript 填充字段,然后触发“确定”按钮单击,进行一些全页加载过渡,甚至看起来不错。

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

编辑:我很好奇,查看了 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);%> />
<% } %>
Run Code Online (Sandbox Code Playgroud)

我查看了反汇编代码,但我认为我们不能将其发布在这里,但这只是证明 UI 从帖子(Request.Form)构建它并查找 CustomTemplate 参数,而 Web 服务只有这些方法如果您无法指定自定义模板。