Example: Developing reports from web service data source
This example details how to use web service as a data source to create reports.
Setting up the web service connection
- Open an existing catalog.
- In the Data tab of the Catalog Browser, select any data source contained in it, click the New Data Source button on the toolbar, then in the New Data source dialog, specify the name of the data source as Medicare Providers, select the Web Service connection type and click OK.
- In the Web Service Data Source dialog, check the URI radio button, and then type the URI string: http://www.webservicex.net/medicareSupplier.asmx?WSDL in the text field to get the WSDL file.
- Keep default settings for other options in the dialog, and then click OK.
Adding a table to the web service connection
- Locate the Tables node in the web service connection, right-click it and select Add Table from the shortcut menu.
- In the Add Table dialog, select GetSupplierByZipCode from the Operation Name drop-down list.
- In the Input Message column, select zip, then in its value column, click and select <Add Parameter...> from the drop-down list.
- In the Create Parameter dialog, input pZipCode as the parameter name in the Name text field.
- Select Type-in Parameter from the Value Setting drop-down list.
- Set the data type of the parameter value to String from the Value Type drop-down list.
- In the Value List box, click to add a value line, click in it and then type in 85226.
- Repeat the above step to add three more values one by one: 80027, 20878, 20874.
- In the Options box, enter Type a zip code as the prompting text.
- Click OK to return to the Add Table dialog.
- Click OK to add the table to the web service connection.
Building a query based on the table
- Locate the Queries node in the data source on which the web service connection is set, right-click it and select Add Query from the shortcut menu.
- Specify the query name as MedicareProvider in the Input Query Name dialog, then click OK.
- In the Query Editor window, click Query > Add Table on the menu bar.
- In the Add Data dialog, select GetSupplierByZipCodeResponse_SupplierDataLists_SupplierDatas_SupplierData in the Tables category, and click the button .
- Click OK, the selected table will be displayed in the Query Editor window. Select all the columns in the table by selecting the * checkbox.
- Click OK to save the query and leave the window.
Developing a report based on the query
- In JReport Designer, click File > New > Page Report on the menu bar.
- In the New Page Report dialog, clear the Report Title text box, and select Banded from the layout box, then click OK.
- In the Table Wizard, select the query MedicareProvider in the data source Medicare Provider in the Data screen.
- In the Display screen, from the Resources box, add the following fields one bye one: SupplierNumber, CompanyName, City and Description.
- Click Next to go to the Group screen, add the field Zip as the group by field.
- Click Finish to create the report.
- Right-click the BandedHeader panel and select Hide from the shortcut menu to hide it from view. Repeat to hide the GroupFooter, BandedPageFooterand BandedFooter panel in the same way.
- Click File > Save on the menu bar to save the report as MedicareProviderInfobyZip.cls.
- Click the View tab to preview the report. The
Enter Parameter Value dialog appears.
- Type a zip code or select the one you want from the drop-down list, and then click OK. The report will be displayed according to your selected parameter value. For example, specify the zip code as 20878, then the report will be displayed as follows, showing information for zip code 20878 only: