前几天写了 Tip - SharePoint列表的SQL Reporting Services报表, 这几天又在研究如何由报表传递参数到SharePoint 列表的web services 方法上。得出如下结论:
1. 值类型的参数象string, integer等RS本来就支持的参数没有什么问题
2. xml类型的参数支持的不好,象GetListItems方法中的query参数为xml类型:
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>string</listName>
<viewName>string</viewName>
<query> <xsd:schema>schema</xsd:schema>xml</query>
<viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit>
<queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID>
</GetListItems>
参数值表达式在报表数据集编辑中的参数编辑框中 输入类似如下的CAML query
<Query>
<Where>
<Geq>
<FieldRef Name="Created" />
<Value Type="DateTime">
<Today />
</Value>
</Geq>
</Where>
</Query>
运行报表,提示web service方法出错,原因是invalid parameter of query! 通过Fiddler观察Soap请求发现,以上参数在soap包中的格式根本不正确, 例如字符 '<' 被转换为"<",显然是被RS html encoded了。
又尝试了CAML参数,报表数据集的查询如下:
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>Test Please History</DefaultValue>
</Parameter>
<Parameter Name="rowLimit">
<DefaultValue>10</DefaultValue>
</Parameter>
<Parameter Name="query" Type="xml">
<DefaultValue>
<Query>
<Where>
<Geq>
<FieldRef Name="Created" />
<Value Type="DateTime">
[parameterDate]
</Value>
</Geq>
</Where>
</Query>
</DefaultValue>
</Parameter>
</Parameters>
</Method>
</Query>
参数parameterDate又无法跟报表参数关联。
可能唯一的办法就写自定义的RS extension来处理xml参数,或使用一些商业产品,例如 Enesys RS Data Extension