Web service Data Source

The following example is going to look at building a report that uses a Web Service Data Source and dataset to retrieve a weather forecast based on a ZIP code. The reason behind my including this separate from the others is the fact that during the first edition of this book there were no real free web services to utilize as an example. However, these days there are plenty of free web services available to utilize for this purpose. Let's now build a report:

  1. Create a new report called WeatherByZipCode.rptdesign.
    Web service Data Sourceaggregationscount aggregation, building
  2. Choose the blank template.
  3. From the Data Explorer, select Data Source | New Data Source.
    Web service Data Sourceaggregationscount aggregation, building
  4. From the list of Data Source types, choose Web Services Data Source, and set Data Source Name as dsWeatherDataSource.
    Web service Data Sourceaggregationscount aggregation, building
  5. As WSDL URL or Location, enter the following URL: http://www.webservicex.net/WeatherForecast.asmx?wsdl. We do not need to fill in any of the other information as it will be retrieved from the WSDL file.
    Web service Data Sourceaggregationscount aggregation, building
  6. Click Finish.
  7. From the Data Explorer, create a new dataset.
    Web service Data Sourceaggregationscount aggregation, building
  8. Call the new dataset as dsetWeatherByZip. Click Next.
    Web service Data Sourceaggregationscount aggregation, building
  9. From the list of available web services, click down to the WeatherForcastSoap and select GetWeatherByZipCode.
    Web service Data Sourceaggregationscount aggregation, building
  10. Click Next for ZipCode parameter as it is the only parameter for this web service.
    Web service Data Sourceaggregationscount aggregation, building
  11. The next screen will show a preview of the web service request. If one is familiar with SOAP request formats, he/she can verify that it is correct. Otherwise, click on Edit Parameter.
    Web service Data Sourceaggregationscount aggregation, building
  12. Click the Edit button and enter ZIP code as the default parameter. Click OK, then click Next at the parent window.
    Web service Data Sourceaggregationscount aggregation, building
  13. For the SOAP response edit dialog, leave all the values as default.
    Web service Data Sourceaggregationscount aggregation, building
  14. The next screen will define an XPATH expression, defining that the rows are in the resulting XML. In this case, we will define a XPATH that points to the result sequence for the weather data. Use the tree view to find the WeatherData node and click on the> arrow, which automatically sets the XPATH expression.
    Web service Data Sourceaggregationscount aggregation, building
  15. On the next screen, we need to define the column mapping for each row. Select the WeatherData node and click on the>> arrow. This will add all the child elements as columns for the resulting row.
    Web service Data Sourceaggregationscount aggregation, building
  16. Click on Show Sample Data to get a preview of the data and verify that the XPATH expressions are retrieving the correct data.
    Web service Data Sourceaggregationscount aggregation, building
  17. Click Close on the sample data dialog, and Finish in the Dataset wizard.
  18. The Edit Data Set dialog will look very familiar at this point. One can go back and modify any of the values set in the wizard. Click OK in the Edit Data Set dialog.
    Web service Data Sourceaggregationscount aggregation, building
  19. Drag the Weather dataset over to the Report Editor.
    Web service Data Sourceaggregationscount aggregation, building
  20. At this point, the report is done. However, let's add something extra to it. The WeatherImage column points to a URL that will have an icon with the weather conditions. Let's put in a dynamic image item that will reflect this. Delete the WeatherImage text item from the second row, second column.
    Web service Data Sourceaggregationscount aggregation, building
  21. Insert a new Image item into the empty second column, second row.
    Web service Data Sourceaggregationscount aggregation, building
  22. In the Edit Image dialog, change the button to the right of the Enter URI textbox to Javascript Syntax.
    Web service Data Sourceaggregationscount aggregation, building
  23. As an expression, enter row["WeatherImage"]. We can use the list boxes at the bottom to input this.
    Web service Data Sourceaggregationscount aggregation, building
  24. Click OK and then click the Insert button.
  25. Save the report and preview it.
Web service Data Sourceaggregationscount aggregation, building

Web service parameters will vary based on the hosting server. It is possible to use Java classes to serve as the web service proxy, if one uses something like Apache Axis. This is a simple example that will get one familiar with the possible uses of this Data Source.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset