原創|使用教程|編輯:郝浩|2013-08-27 15:13:05.000|閱讀 381 次
概述:由于FastReport .Net版本擁有了自己的WCF服務庫——FastReport.Service.dll,所以現在有一個更簡單的方法實現Web報表服務了。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
由于FastReport .Net版本擁有了自己的WCF服務庫——FastReport.Service.dll,所以現在有一個更簡單的方法實現Web報表服務了。
使用.NET Framework 4.0或以上版本,就可以在現有項目技術上進行非常簡單的修改,實現建立在Web服務基礎上的Web報表應用了。接下來介紹一下通用的使用步驟。
1、.NET Framework 4.0下打開Visual Studio并創建一個新的ASP.NET Web Application的項目。
2、添加引用庫FastReport.dll,FastReport.Bars.dll,FastReport.Service.dll。
3、在站點根目錄上創建一個名為ReportService.svc的文筆文件。
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.dll,FastReport.Bars.dll,FastReport.Service.dll要在/ bin文件夾中。
Web服務連接成功后,就在可以在Visual Studio中打開現有項目,點擊ReportService選擇Configure Service Reference設置就行了。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網