原創(chuàng)|使用教程|編輯:郝浩|2013-08-27 15:13:05.000|閱讀 381 次
概述:由于FastReport .Net版本擁有了自己的WCF服務(wù)庫——FastReport.Service.dll,所以現(xiàn)在有一個(gè)更簡單的方法實(shí)現(xiàn)Web報(bào)表服務(wù)了。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
由于FastReport .Net版本擁有了自己的WCF服務(wù)庫——FastReport.Service.dll,所以現(xiàn)在有一個(gè)更簡單的方法實(shí)現(xiàn)Web報(bào)表服務(wù)了。
使用.NET Framework 4.0或以上版本,就可以在現(xiàn)有項(xiàng)目技術(shù)上進(jìn)行非常簡單的修改,實(shí)現(xiàn)建立在Web服務(wù)基礎(chǔ)上的Web報(bào)表應(yīng)用了。接下來介紹一下通用的使用步驟。
1、.NET Framework 4.0下打開Visual Studio并創(chuàng)建一個(gè)新的ASP.NET Web Application的項(xiàng)目。
2、添加引用庫FastReport.dll,F(xiàn)astReport.Bars.dll,F(xiàn)astReport.Service.dll。
3、在站點(diǎn)根目錄上創(chuàng)建一個(gè)名為ReportService.svc的文筆文件。
4、在文本中增加以下代碼:
<%@ ServiceHost Service="FastReport.Service.ReportService" %> <%@ Assembly Name="FastReport.Service" %>
5、打開web.config,在<configuration>節(jié)中增加以下代碼:
<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是報(bào)表文件夾的路徑,本示例中的路徑是“\FastReport.Net\Demos\WCF”
FastReport.ConnectionStringName是連接字符串名稱,應(yīng)在<connectionStrings>中注冊(cè)。
6、運(yùn)行站點(diǎn),來檢查Web服務(wù)的可用性,出現(xiàn)以下頁面便運(yùn)行成功。
注意:在服務(wù)器上部署項(xiàng)目時(shí),F(xiàn)astReport.dll,FastReport.Bars.dll,F(xiàn)astReport.Service.dll要在/ bin文件夾中。
Web服務(wù)連接成功后,就在可以在Visual Studio中打開現(xiàn)有項(xiàng)目,點(diǎn)擊ReportService選擇Configure Service Reference設(shè)置就行了。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)