FRAMES | NO FRAMES

Using the BAOReportHelper Class

Business Analyst Online API SOAP Services samples use an optional BAOReportHelper class for executing methods of the Business Analyst Online API SOAP Web Services BAOReport endpoint. To download this class together with auxiliary files, click the link below or right click the link and choose "Save as..." in the pop-up menu.

Download BAOReportHelper zip archive (C#)

Download BAOReportHelper zip archive (VB.NET)

This package contains the following files.

Filename Description
BAOReportHelper C# or VB.NET helper class to the Business Analyst Online API SOAP Web Services BAOReport endpoint.
HTTPTokenProvider C# or VB.NET token provider class using the HTTPS SSL connection.
ITokenProvider C# or VB.NET token provider interface.
TokenProvider C# or VB.NET base token provider class.

The BAOReportHelper class simplifies an execution of methods of the BAOReport endpoint. It provides an automatic update of the authentication token when the last one expires. It executes every method of the BAOReport endpoint within a try-catch block and catches the "Token Expired" exception. If this exception occurs, the BAOReportHelper class requests a new token and executes the method with the new token.

The BAOReportHelper class makes token management easier when used in conjunction with the Business Analyst Online API SOAP Services methods. Token management functionality includes automatic association of a token with SOAP API methods and retrieval of a new token when the current token expires. To leverage the helper class, simply associate an authentication token provider object implementing the ITokenProvider interface with a BAOReportHelper instance as demonstrated in the code snippets below.

In the Business Analyst Online API SOAP Services samples, the HTTPTokenProvider class is used as the authentication token provider. It saves user credentials, the user name and password, in private instance members and applies the secured REST Get Token method (see Get Token Samples) when the token update is necessary. If you don't want to save the user credentials, you can implement a version of the token provider, which requests a user name and password in a dialog, when a new token is requested.

Because the BAOReportHelper class automatically generates an authentication token, the signature of some methods of the BAOReportHelper class differs from the signature of corresponding methods of the BAOReport class. For example, the BAOReportHelper.GetStandardGeographyLevels method has no parameters but the BAOReport.GetStandardGeographyLevels method has one token parameter. The BAOReportHelper.chm help file describes the API for the BAOReportHelper and auxiliary classes introduced in this package.

How to Install the BAOReportHelper Class

Notes: In order to help you rapidly get acquainted with, learn how to use and consume the Business Analyst Online API SOAP Services, we have provided complete downloadable Visual Studio C# and VB.NET examples that already reference a SOAP proxy class ("pre-created" using the steps below) and are ready to run. Additionally, there are code examples within the documentation and in the complete Visual Studio C# and VB.NET solutions that consume the Business Analyst Online API SOAP Services through the BAOReportHelper class and through the regular proxy class generated from the BAOReport WSDL endpoint. Please refer to the documentation pages for the individual methods to obtain the links to the current C# and VB.NET Visual Studio solutions.


  1. Extract files from the BAOReportHelper zip archive (C#) or BAOReportHelper zip archive (VB.NET) archive.
  2. Add all C# or VB.NET files from this archive to your project containing the web reference to the Business Analyst Online API SOAP Web Service proxy and value objects. See Add a Reference to Esri Business Analyst Online API SOAP Services for details on adding a web reference.
  3. Replace the ESRI.BAOnline.SOAP.BAOReports namespace in the using instruction of the BAOReportHelper file with the namespace of your web reference to the Business Analyst Online API SOAP Web Service proxy and value objects.

C#
using YourApplicationNamespace.YourBAOReportProxyReference;

VB.NET
Imports YourApplicationNamespace.YourBAOReportProxyReference

NOTES: In Visual Studio 2008 and 2010, you can add a service reference to the Business Analyst Online API SOAP Web Service instead of a web reference. In this case, the BAOReportClient class is generated instead of BAOReport class. In order to use the BAOReportHelper class with the service reference, rename all occurrences of the BAOReport class name within the BAOReportHelper file with the BAOReportClient name.

How to Use the BAOReportHelper Class


Classes of this package belong to the ESRI.BAOnline.SOAP namespace. To simplify work with these classes, appropriately reference the namespace in the header of your files which will consume and reference the Business Analyst Online API SOAP Services.

C#
using ESRI.BAOnline.SOAP;

VB.NET
Imports YourApplicationNamespace.ESRI.BAOnline.SOAP;

 

Before creating an instance of the BAOReportHelper class, you need to create a token provider. The code below shows how to create an instance of the HTTPTokenProvider class. (This code is provided in all of the SOAP code samples which leverage the BAOReportHelper class.)

C#
string tokenServiceUrl = "https://baoapi.esri.com/bawebservices/rest/authentication";
string username = "BAOAPISAMPLE"; // Substitute user name here
string password = "baoapisample"; // Substitute password here
ITokenProvider tokenProvider = new HTTPTokenProvider(tokenServiceUrl, username, password);

VB.NET
Dim tokenServiceUrl As String = "https://baoapi.esri.com/bawebservices/rest/authentication"
' Substitute user name here
Dim username As String = "BAOAPISAMPLE" 
' Substitute password here
Dim password As String = "baoapisample"
Dim tokenProvider as ITokenProvider = _
  New HTTPTokenProvider(tokenServiceUrl, username, password)

 

OPTIONAL: If you wish to leverage the BAOReportHelper class and you already have a non-expired token, you can assign it to the ITokenProvider.CurrentToken property:

C#
tokenProvider.CurrentToken = nonExpiredToken;  // Optional

VB.NET
' Optional
tokenProvider.CurrentToken = nonExpiredToken

 

Now you can create an instance of the BAOReportHelper class and execute its methods. The example below executes the GetReportTemplates method. (Be sure to add execution break points or access the properties of resulting object in order to interrogate the result.)

C#
BAOReportHelper baoReportHelper = new BAOReportHelper(tokenProvider);
 
ReportTemplateInfo[] templates = baoReportHelper.GetReportTemplates(Nothing);

VB.NET
Dim baoReportHelper As New BAOReportHelper(tokenProvider)

Dim templates  As ReportTemplateInfo() = baoReportHelper.GetReportTemplates(null)

 

The BAOReportHelper class implements each Business Analyst Online API SOAP Service method and provides some token management functionality. While you are not required to leverage the BAOReportHelper class, it can make developing with the Business Analyst Online API SOAP Services even easier.

The full source is available for viewing when you download the source supporting the BAOReportHelper class:

Download BAOReportHelper zip archive (C#)

Download BAOReportHelper zip archive (VB.NET)


BAOReport vs BAOReportHelper

Users have the option to consume the Business Analyst Online API SOAP Services through the BAOReportHelper class. This class has some token management functionality and also automatically specifies default values for some parameters when making Business Analyst Online API SOAP Services requests. The code snippets below highlight some of the differences that exist between consuming the BAOReport proxy class by itself and consuming the proxy class through the BAOReportHelper class. All of the SOAP code samples included in the documentation include working code samples for both options and in both C# and VB.NET languages.

BAOReport (C#)

BAOReportHelper (C#)

string token;
// Get token here...
 
string webServiceUrl;
// Specify BAOReport Web Service URL here...
 
BAOReport baoReport = new BAOReport();
baoReport.Url = webServiceUrl;
 
 
SimpleRingsParameters parameters = new SimpleRingsParameters();
parameters.token = token;
// Specify other properties of SimpleRingsParameters here...
 
// Specify other parameters
RenderingParameters imageOptions = null;
TaskOutputType[] outputOptions =
new TaskOutputType[] { TaskOutputType.GetFeatureClass };
 
// Execute the task
TaskResultOutput result =
baoReport.SimpleRings(parameters, imageOptions, outputOptions);
ITokenProvider tokenProvider;
// Specify token provider here...
 
string webServiceUrl;
// Specify BAOReport Web Service URL here...
 
BAOReportHelper baoReportHelper = new BAOReportHelper(tokenProvider);
baoReportHelper.Client.Url = webServiceUrl;
 
SimpleRingsParameters parameters = new SimpleRingsParameters();
// Token assignment is useless here
// Specify other properties of SimpleRingsParameters here...
 
// Specify other parameters
RenderingParameters imageOptions = null;
TaskOutputType[] outputOptions =
new TaskOutputType[] { TaskOutputType.GetFeatureClass };
 
// Execute the task
TaskResultOutput result =
baoReportHelper.SimpleRings(parameters, imageOptions, outputOptions);