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

报表生成器FastReport .Net程序员手册:使用FastReport.Service.dll创建Web服务

来源:   发布时间:2021-04-01   浏览:次

FastReport .Net是适用于Windows Forms,ASP.NET,MVC和.NET Core的全功能报表解决方案。它可以在Microsoft Visual Studio 2005-2019中使用。支持.Net Framework 2.0-4.x,.NET Core 3.0及以上版本。

在FastReport .NET 2021.1的新版本中,我们实现了对.NET 5的支持。添加了新条形码-Deutsce Post Leitcode。将RTF转换为报告对象的算法已得到显着改进。并且还添加了用于转换数字的新功能。欢迎下载体验。(点击下方按钮下载)

立即点击下载FastReport.NET v2021.1最新版

Fastreport.NET在线购买价更低,专享85折起!赶紧加入购物清单吧!

使用FastReport .Net提供的库FastReport.Service.dll(WCF服务库)实现网络服务有一个简单的方法。

我们的例子是基于创建一个具有web服务功能的简单web应用程序,但您可以基于.NET Framework 4.0或更高版本修改您现有的项目。

运行Visual Studio并在.NET Framework 4.0下创建一个新的ASP.NET Web应用程序项目。

添加对库FastReport.dll、FastReport.Bars.dll、FastReport.Service.dll的引用 在站点根目录下创建一个名称为ReportService.svc的新文本文件。

在文件中添加以下几行内容。

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

打开web.config,在<配置>部分添加这段代码。

<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.Net\Demos\WCF"。

键 "FastReport.ConnectionStringName "应该包含连接字符串名称。这一行应该在<connectionStrings>部分注册。

让我们运行我们的网站,通过访问文件ReportService.svc来检查Web服务的可用性。

当你在服务器上部署项目时,一定要检查文件FastReport.dll,FastReport.Bars.dll、FastReport.Service.dll是否在文件夹\bin中。

客户端程序的例子可以在文件夹 \FastReport.Net/Demos/C#/WCFClient 和 \FastReport.Net/Demos/C#/WCFWebClient 中找到。在Visual Studio中打开每个项目,右击ReportService,在弹出的对话框中选择配置服务参考。

在配置窗口中指定现有Web服务的地址。

还想要更多吗?您可以点击阅读【FastReport 报表2020最新资源盘点】,查找需要的教程资源。让人兴奋的是FastReport .NET报表正在慧都网火热销售中!低至3701元起!>>查看价格详情

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

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


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