Show Me |
|---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E2876。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |
此示例展示了如何使用 ServiceReferences.ClientConfig 文件来配置 ReportService(报表服务) 的客户端选项。
在下面显示了 ServiceReferences.ClientConfig 文件的内容。
| Xml | 复制代码 |
|---|---|
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicBindingConfiguration"
closeTimeout="00:33:00"
openTimeout="00:33:00"
sendTimeout="00:33:00"
receiveTimeout="00:33:00"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="endpointConfiguration"
address="../ReportService1.svc"
binding="basicHttpBinding"
bindingConfiguration="basicBindingConfiguration"
contract="ServiceReference.IReportService" />
</client>
</system.serviceModel>
</configuration>
| |
注意,不能把 ReportPreviewModel.ServiceUri 属性设置为空字符串,因此应该在 XAML 中始终至少指派一个代用值。
| Xaml | 复制代码 |
|---|---|
(MainPage.xaml) <UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing" xmlns:local="clr-namespace:SilverlightApplication1"> <!--#region documentPreview--> <dxp:DocumentPreview AutoCreateDocument="True"> <dxp:DocumentPreview.Model> <dxp:ReportPreviewModel ReportTypeName="XtraReport1" ServiceUri="."> <dxp:ReportPreviewModel.ServiceClientFactory> <local:MyServiceClientFactory EndpointConfigurationName="endpointConfiguration" /> </dxp:ReportPreviewModel.ServiceClientFactory> </dxp:ReportPreviewModel> </dxp:DocumentPreview.Model> </dxp:DocumentPreview> <!--#endregion documentPreview--> </UserControl> | |
| C# | 复制代码 |
|---|---|
(MyServiceClientFactory.cs) using System; using System.ServiceModel; using System.ServiceModel.Channels; using DevExpress.Xpf.Printing; using DevExpress.Xpf.Printing.ServiceReference; // ... namespace SilverlightApplication1 { public class MyServiceClientFactory : IServiceClientFactory { public string EndpointConfigurationName { get; set; } #region IServiceClientFactory Members public Binding Binding { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } public ServiceClient Create(EndpointAddress serviceAddress) { return new ServiceClient(EndpointConfigurationName); } #endregion } } | |
| Visual Basic | 复制代码 |
|---|---|
(MyServiceClientFactory.vb) Imports System Imports System.ServiceModel Imports System.ServiceModel.Channels Imports DevExpress.Xpf.Printing Imports DevExpress.Xpf.Printing.ServiceReference ' ... Namespace SilverlightApplication1 Public Class MyServiceClientFactory Implements IServiceClientFactory Private privateEndpointConfigurationName As String Public Property EndpointConfigurationName() As String Get Return privateEndpointConfigurationName End Get Set(ByVal value As String) privateEndpointConfigurationName = value End Set End Property #Region "IServiceClientFactory Members" Public Overloads Property Binding() _ As Binding Implements IServiceClientFactory.Binding Get Throw New NotSupportedException() End Get Set(ByVal value As Binding) Throw New NotSupportedException() End Set End Property Public Overloads Function Create(ByVal serviceAddress As EndpointAddress) _ As ServiceClient Implements IServiceClientFactory.Create Return New ServiceClient(Me.EndpointConfigurationName) End Function #EndRegion End Class End Namespace | |
在下面的插图中显示了结果。

Show Me 