Using WCF endpoints with SQL Reporting Services

Consuming WCF endpointpoints with SQL Reporting Services can be difficult. Most of this difficulty is for two reasons:

1) SQL Reporting Services XML and web services support is slightly better than a piece of crap.

2) Documentation for the XML query provider in SQL Reporting Services blows.

One of the big problems with SSRS is that you can't just point it to a WSDL document and have it generate a proxy. In fact, the way you use web service data is virtually the same as querying off a static XML document. However, it is possible to get the two working together. Here are the steps:

1) Expose your WCF service using BasicHttpBinding.

2) Select XML data source and enter the url of your service, ie. http://myserver.com/service.svc

3) Enter the XML for your query:

<Query>

<Method Name="MyMethodRequest" Namespace="http://tempuri.org/">

   <Parameters>

       <Parameter Name="Param1"><DefaultValue>ABC</DefaultValue></Param>

   </Parameters>

</Method>

<SoapAction>http://tempuri.org/MyService/MyMethod</SoapAction>

</Query>

 4) Make sure your WCF proxy is set up properly to work with SSRS:


[MessageContract(IsWrapped=true)]
public class MyMethodRequest
{
    [MessageBodyMember]
     public string Param1;
}

[ServiceContract]
public interface MyService
{
   [OperationContract]
   MyMethodResponse MyMethod(MyMethodRequest request);
}

Notice a few things. First, you will want your request to be wrapped. By default, the method name in your SSRS query must match the class name of your request. If you want to change your wrapper name, that is ok, but make sure to keep the wrapper name / namespace in sync with the Method element in SSRS. If you specify a custom action on your OperationContract, make sure that the soap action matches that action.

If you get an error message when you try to connect, remember these two things:

1) The error dialog has a details button where you can drill down and get more detailed information about the error that occured on the server, rather than the generic useless error it gives you.

2) If the details on the error dialog aren't giving you enough information, enable message tracing on your WCF service. If you aren't familiar enough with the WS specs or WCF to know what is wrong with the communication, create a quick app that calls the service using WCF and then compare a trace between the SSRS call and your sample app.

As a final note, watch out for missing or extra trailing slashes in namespaces and make sure everything is cased properly. One missing or extra slash or one improperly cased character can hose the entire request.

Published Thursday, February 21, 2008 7:39 AM by Jesse Ezell

Comments

# links for 2008-02-21 &laquo; dstelow notes&#8230;

Thursday, February 21, 2008 6:42 PM by links for 2008-02-21 « dstelow notes…

Pingback from  links for 2008-02-21 &laquo; dstelow notes&#8230;

# re: Using WCF endpoints with SQL Reporting Services

Friday, May 02, 2008 3:11 PM by Nilesh

still used 2.0 .Net framework and using a reportviewer control for SSRS. what's advanatage of WCF for SSRS?

# re: Using WCF endpoints with SQL Reporting Services

Tuesday, June 17, 2008 6:10 PM by frankwise

This is rather disappointing.  I was planning on layering WCF over a legacy database and reporting with SSRS.  Anyone know if the SSRS on Sql Server 2008 will have improved support for WCF interaction?

# re: Using WCF endpoints with SQL Reporting Services

Monday, January 12, 2009 5:35 AM by kevin

How do u set your wcf proxy to work with ssrs

# re: Using WCF endpoints with SQL Reporting Services

Thursday, March 12, 2009 4:52 PM by Dan Lash

Is it possible to connect to a WCF service that uses the wsHtppBinding?

Leave a Comment

(required) 
(required) 
(optional)
(required)