This is a migrated thread and some comments may be shown as answers.

Silverlight ReportViewer InnerException[self-Host WcfService]

2 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wang
Top achievements
Rank 1
Wang asked on 11 Aug 2011, 06:43 AM

1、Create Self-Host  Report  WcfService
------------------------------------------------------------------------------------------------
WCFService Library Application:WCF Service Library Project
------------------------------------------------------------------------------------------------
ReportLibrary.ReportService.cs

namespace ReportLibrary
{
    [System.Runtime.Serialization.KnownType(typeof(object[]))]
    public class ReportService : Telerik.Reporting.Service.ReportServiceBase
    {
        private static readonly Uri baseUri = new Uri("http://localhost:9009/Telerik/ReportService/");
        protected override Uri BaseAddress
        {
            get { return baseUri; }
        }
    }
}

app.config

<!-- Telerik.Reporting.Service.IReportService -->
    <service name="ReportLibrary.ReportService" behaviorConfiguration="serviceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9002/Telerik/ReportService/"/>
        </baseAddresses>
      </host>
  
      <endpoint address=""
                binding="customBinding"  bindingConfiguration="WcfServiceCustomBinding0"
                contract="Telerik.Reporting.Service.IReportService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
  
      <endpoint address="ResourceService" 
                binding="webHttpBinding"
                behaviorConfiguration="WebBehavior"
                contract="Telerik.Reporting.Service.IResourceService"/>
  
        <endpoint address="ClientAccessPolicy" 
                  binding="webHttpBinding"  behaviorConfiguration="WebBehavior"
                  contract="Telerik.Reporting.Service.IClientAccessPolicy"/>
  
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>

Build Success And Output:
ReportLibrary\bin\Debug\ReportLibrary.dll
ReportLibrary\bin\Debug\Telerik.Reporting.Service.dll

------------------------------------------------------------------------------------------
WcfHost Console Application:WCF Self-Host Console Project
------------------------------------------------------------------------------------------
WcfHost.Program.cs

namespace WcfHost
{
    public class Program
    {
        public static void Main(string[] args)
        {
            ServiceHost hostA = null;
            ServiceHost hostDomain = null;
            try
            {
                hostA = new ServiceHost(typeof(ReportLibrary.ReportService));
                hostDomain = new ServiceHost(typeof(DomainService));
  
                hostA.Open();hostDomain.Open();
  
                Console.WriteLine("Report Services is starting...");
                Console.WriteLine("CrossDomain Service is starting...");
  
                Console.WriteLine();
                Console.WriteLine("Press <ENTER> to terminate host");
                Console.ReadLine();
  
                hostA.Close();
                hostDomain.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
            finally
            {
                hostA.Close();
            }
        }
    }
}

app.config

<service behaviorConfiguration="serviceBehavior" name="ReportLibrary.ReportService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:9002/Telerik/ReportService/" />
          </baseAddresses>
        </host>
          
        <endpoint address="" binding="customBinding" bindingConfiguration="WcfServiceCustomBinding0"
          contract="Telerik.Reporting.Service.IReportService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
          
        <endpoint address="ResourceService"
                binding="webHttpBinding"  
                behaviorConfiguration="WebBehavior" 
                contract="Telerik.Reporting.Service.IResourceService"/>
  
        <endpoint address="ClientAccessPolicy"
                  binding="webHttpBinding" behaviorConfiguration="WebBehavior"
                  contract="Telerik.Reporting.Service.IClientAccessPolicy"/>
          
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          
      </service>

Build Success And Output:
WcfHost\bin\Debug\ReportLibrary.dll
WcfHost\bin\Debug\Telerik.Reporting.Service.dll
WcfHost\bin\Debug\WcfHost.exe

Run WcfHost.exe Carrying ReportLibrary.ReportService Wcf Service;
service endpoint Address = "http://localhost:9002/Telerik/ReportService/"; by normal browser access wcf service

2、Create Wcf Client

------------------------------------------------------------------------------------------------------
ReportSLApp Silverlight Application:Wcf Silverlight Client Project

Add Reference:Reporting Q1 2011\bin\Telerik.ReportViewer.Silverlight.dll;
------------------------------------------------------------------------------------------------------
ServiceReferences.ClientConfig

<endpoint address="http://localhost:9002/Telerik/ReportService/"
                binding="customBinding" bindingConfiguration="CustomBinding_IReportService"
                contract="ReportServiceRef1.IReportService" name="CustomBinding_IReportService" />

ReportSLApp.MainPage.xaml.cs

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    ServiceClient = new ReportServiceRef1.ReportServiceClient("CustomBinding_IReportService");
            ServiceClient.ListAvailableReportsCompleted += new 
  
EventHandler<ReportServiceRef1.ListAvailableReportsCompletedEventArgs>(ServiceClient_ListAvailableReportsCompleted);
            ServiceClient.ListAvailableReportsAsync();
  
            this.rptViewer1.ReportServiceUri = ServiceClient.Endpoint.Address.Uri;
}
private void ServiceClient_ListAvailableReportsCompleted(object sender,
ReportServiceRef1.ListAvailableReportsCompletedEventArgs e)
        {
              
                if (e.Error == null)
                {
                    MyReports = e.Result;
                      
                    this.rptViewer1.Report = MyReports[0].FullName;
                }
              
        }

Build Success And Browse Silverlight HostPage:

ReportSLAppTestPage.aspx error occurred operating results; Silverlight ReportViewer InnerException

I urgently need help, wait ...

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 15 Aug 2011, 03:52 PM
Hi Wang,

We have tested the self hosted WCF service with your approach of getting the reports list and we didn't experience any exceptions. Check out the attached sample for self hosted WCF service.
However we have noticed that you have defined custom bindings that you haven't shared. Thus our suggestion is to try with the default bindings as in the sample in order to isolate if the issue is related to bindings configuration.

All the best,
Peter
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Lategan
Top achievements
Rank 1
answered on 11 Jul 2012, 08:55 AM
Hi Peter

Could you please provide a complete working example, both Silverlight and self-hosted WCF, I cant seem to get this working?

Regards,
Lategan Botha
Tags
General Discussions
Asked by
Wang
Top achievements
Rank 1
Answers by
Peter
Telerik team
Lategan
Top achievements
Rank 1
Share this question
or