SOAP call with query on result (SSRS, Sharepoint)

前端 未结 4 1308
梦如初夏
梦如初夏 2020-12-21 06:20

I created a report in VS using a shared data source which is connected to a sharepoint list. In the report I created a dataset with a SOAP call to the data source so I get t

相关标签:
4条回答
  • 2020-12-21 06:44

    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>.

    0 讨论(0)
  • 2020-12-21 06:47

    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>"
    
    0 讨论(0)
  • 2020-12-21 07:03

    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>

    0 讨论(0)
  • 2020-12-21 07:04

    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_

    0 讨论(0)
提交回复
热议问题