Simple example of WCF service
This example does not require programming and is intended for testing the library and the configuration file. To complete the task, we will use the program WcfSvcHost.exe, that comes with Visual Studio:
Create a folder for our project anywhere on the disk, eg: as C:\WCF\FastReport
Copy these files to the folder:
FastReport.Service.dll
,FastReport.Service.dll.config
,FastReport.dll
andFastReport.Bars.dll
Create two sub-folders \Data and \Reports
Copy the database file to the \Data folder from the Demos folder \Demos\Reports\nwind.xml
Copy the contents of folder \Demos\Reports to \Reports – it contains test reports with built-in connections to the database, which are essential when used with library
FastReport.Service.dll
Open the configuration file
FastReport.Service.dll.config
in any text editorChange the path to the reports in section
<appSettings>
<add key="FastReport.ReportsPath" value="C:\WCF\FastReport\Reports" />
- Change the connection string in section
<connectionStrings>
:
<add name="FastReportDemo" connectionString="XsdFile=;XmlFile=C:\WCF\FastReport\Data\nwind.xml"/>
- Create batch file service.bat containing the line:
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\WcfSvcHost.exe" /service:"C:\WCF\FastReport\FastReport.Service.dll" /config:"C:\WCF\FastReport\FastReport.Service.dll.config"
- Run service.bat from Explorer with administrator rights (Run as administrator). You will see an icon for WCF Service Host in the system tray. Double-click on the icon:
- Open a web browser and go to address http://localhost:8732/FastReportService/
This shows the Service working normally. You can change the port number of the service in the configuration file:
<add baseAddress="http://localhost:8732/FastReportService/" />