SOAP call with query on result (SSRS, Sharepoint)

随声附和 提交于 2019-11-29 15:11:39

A post at:

http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/1562bc7c-8348-441d-8b59-245d70c3d967/

Suggested using this syntax for placement of the <Query> node (this example is to retrieve the item with an ID of 1):

<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>{CE7A4C2E-D03A-4AF3-BCA3-BA2A0ADCADC7}</DefaultValue>
      </Parameter>
      <Parameter Name="query" Type="xml">
        <DefaultValue>
          <Query>
            <Where>
              <Eq>
                <FieldRef Name="ID"/>
                <Value Type="Integer">1</Value>
              </Eq>
            </Where>
          </Query>
        </DefaultValue>
      </Parameter>
    </Parameters>
  </Method>
  <ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>

However this would give me the following error:

Failed to execute web request for the specified URL

With the following in the details:

Element &lt;Query&gt; of parameter query is missing or invalid

From looking at the SOAP message with Microsoft Network Monitor, it looks as though the <Query> node is getting escaped to &lt;Query&gt; etc, which is why it fails.

However, I was able to get this to work using the method described in Martin Kurek's response at:

http://www.sharepointblogs.com/dwise/archive/2007/11/28/connecting-sql-reporting-services-to-a-sharepoint-list-redux.aspx

So, I used this as my query:

<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>{CE7A4C2E-D03A-4AF3-BCA3-BA2A0ADCADC7}</DefaultValue>
         </Parameter>
         <Parameter Name="query" Type="xml">
        </Parameter>   
      </Parameters>
   </Method>
   <ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>

And then defined a parameter on the dataset named query, with the following value:

<Query><Where><Eq><FieldRef Name="ID"/><Value Type="Integer">1</Value></Eq></Where></Query>

I was also able to make my query dependent on a report parameter, by setting the query dataset parameter to the following expression:

="<Query><Where><Eq><FieldRef Name=""ID""/><Value Type=""Integer"">" & 
Parameters!TaskID.Value & 
"</Value></Eq></Where></Query>"
Alex Angas

See the question and answers for GetListItems Webservice ignores my query filter. This shows you how (and how not to) set up your SOAP call to include a query. You probably need to wrap your query with another <Query></Query>.

You have your FieldRef as

ows_Title

I believe it should just be Title.

When you get results from the SOAP request all your field name will begin with

ows_

Brilliant, thanks. This solution worked for queryOptions also.

In the Query:

<Parameter Name="queryOptions" Type="xml">
</Parameter>

And in the parameters list of the dataset:

Name: queryOptions

Value: <QueryOptions><Folder>Shared Documents/MyFolder</Folder></QueryOptions>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!