Friday, February 21, 2014

How to use a WCF service as SSRS 2008 R2 datasource

This article explains how to use WCF services that can return Lists of type T as datasource and dataset for a reporting services report. this is one of the many articles you can find on the web, who will each tell theri version of the story.

In another blog post i explain How to create a WCF service that can be consumed by SSIS or SSRS

Walkthrough

Create a Report Server project with BI Development studio 2008 R2. In the example it is called ConsumeWCF.

image

In the solution explorer rightclick on Shared Data Sources and Add New Data Source

image

  • Name: dsrc_SysAComm
  • Type: XML
  • Connection string: http://<insert your hostname>/SysAService/SysAComm.svc
  • image
  • click OK
In the solution explorer rightclick on Shared Datasets and Add New DataSet

image

  • Name: dset_Devicelist
  • Data source: dsrc_SysAComm
  • query Type: text
  • Query:
    <Query>
    <Method Name="GetDeviceList" Namespace="http://tempuri.org/">
        <Parameters>
            <Parameter Name="LocationCode"><DefaultValue>A123</DefaultValue></Parameter>
        </Parameters>
    </Method>
    <SoapAction>http://tempuri.org/ISysAComm/GetDeviceList</SoapAction>
    </Query>

  • To design and test the query, you can click the ‘Query Designer’ button. Note that the design feature is no more than a notepad-style text editor, but at least you can run the query to test for any syntax error.
    image
  • Save this shared dataset. It is now ready to be used as a dataset for a new blank report


SSRS Query syntax short explanation


Use the WCF Test Client to get some indication of the necessary key words. Personally I did not even try to use namespaces other than the standard tempuri.org. If you do not have the source code of the WCF service, then you can start WcfTestclient from the Developer command prompt for VS 2012. If you only have BI development studio 2008 and no VS2012, you can download a free version of SoapUI, which can be used like WcfTestclient


For starters have a look at the WCF Test client screenshot of the WCF service:


image



  • <Query></Query> start and close the Query
  • <Method> define the Name, Namespace (http://tempuri.org/ !mind the ending slash sign) and the parameters

    • <Method Name=”GetDeviceList” Namespace="http://tempuri.org/"> … parameters … </Method>

      • specify the name of the parameter
      • <Parameters><Parameter Name=”LocationCode”> …optional default value … </Parameter>

  • <SoapAction> this single line is built with the Method Namespace, Interface service name and method name.

    • <SoapAction>http://tempuri.org/ISysAComm/GetDeviceList</SoapAction>

No comments: