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