FastReport中国社区FastReport联系电话 联系电话:023-68661681

使用FastReport.Service.dll创建Web报表服务

来源:   发布时间:2016-08-08   浏览:3219次

由于FastReport .Net版本拥有了自己的WCF服务库——FastReport.Service.dll,所以现在有一个更简单的方法实现Web报表服务了。

使用.NET Framework 4.0或以上版本,就可以在现有项目技术上进行非常简单的修改,实现建立在Web服务基础上的Web报表应用了。接下来介绍一下通用的使用步骤。

1、.NET Framework 4.0下打开Visual Studio并创建一个新的ASP.NET Web Application的项目。

使用FastReport.Service.dll创建Web报表服务

2、添加引用库FastReport.dll,FastReport.Bars.dll,FastReport.Service.dll。

3、在站点根目录上创建一个名为ReportService.svc的文笔文件。

使用FastReport.Service.dll创建Web报表服务

4、在文本中增加以下代码:

<%@ ServiceHost Service="FastReport.Service.ReportService" %>
 
<%@ Assembly Name="FastReport.Service" %>

5、打开web.config,在<configuration>节中增加以下代码:

<appSettings>
 <!-- path to folder with reports -->
 <add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" />
 <!-- name of connection string for reports -->
 <add key="FastReport.ConnectionStringName" value="FastReportDemo" />
 <!-- Comma-separated list of available formats PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX.
 You can delete any or change order in this list. -->
 <add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" />
 </appSettings>
 <connectionStrings>
 <add name="FastReportDemo" connectionString="XsdFile=;XmlFile=C:\Program Files\FastReports\FastReport.Net\Demos\Reports\nwind.xml"/>
 </connectionStrings>
 <system.serviceModel>
 <services>
 <service behaviorConfiguration="FastReportServiceBehavior" name="FastReport.Service.ReportService">
 <endpoint address="" binding="wsHttpBinding" contract="FastReport.Service.IFastReportService">
 <identity>
 <dns value="localhost" />
 </identity>
 </endpoint>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
 </service>
 </services>
 <behaviors>
 <serviceBehaviors>
 <behavior name="FastReportServiceBehavior">
 <serviceMetadata httpGetEnabled="True" />
 <serviceDebug includeExceptionDetailInFaults="True" />
 </behavior>
 </serviceBehaviors>
 </behaviors>
 <bindings>
 <basicHttpBinding>
 <binding messageEncoding="Mtom"
 closeTimeout="00:02:00" openTimeout="00:02:00"
 receiveTimeout="00:10:00" sendTimeout="00:02:00"
 maxReceivedMessageSize="67108864" maxBufferSize="65536"
 transferMode="Streamed">
 <security mode="None">
 <transport clientCredentialType="None" />
 </security>
 </binding>
 </basicHttpBinding>
 </bindings>
 </system.serviceModel>

注意:FastReport.ReportsPath是报表文件夹的路径,本示例中的路径是“\FastReport.Net\Demos\WCF”

FastReport.ConnectionStringName是连接字符串名称,应在<connectionStrings>中注册。

6、运行站点,来检查Web服务的可用性,出现以下页面便运行成功。

使用FastReport.Service.dll创建Web报表服务

注意:在服务器上部署项目时,FastReport.dll,FastReport.Bars.dll,FastReport.Service.dll要在/ bin文件夹中。

Web服务连接成功后,就在可以在Visual Studio中打开现有项目,点击ReportService选择Configure Service Reference设置就行了。

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:FastReport控件中文网 [https://www.fastreportcn.com/]
本文地址:https://www.fastreportcn.com/post/1238.html

联系我们
  • 重庆总部 023-68661681
购买
  • sales@evget.com
合作
  • business@evget.com


在线
客服
微信
QQ 电话
023-68661681
返回
顶部