Scheduling a ReportCaster Job With a WebFOCUS Report

By Efrem Litwin

In the February 2005 issue of WebFOCUS Newsletter, I wrote an article explaining how a .NET or Java application can be used to integrate with ReportCaster functionality (“Scheduling Reports with .Net”). This is done through the use of ReportCaster Web Services. Applications can be written with a customized front-end with ReportCaster functionality such as scheduling jobs, address book maintenance, console management, user maintenance, library access maintenance, library report retrieval, library maintenance, log retrieval and log maintenance. 

Over the past couple of years, I’ve received questions as to whether ReportCaster Web Services can be used in conjunction with our Web Services adapter. This would give WebFOCUS developers the ability to create WebFOCUS Reports that perform ReportCaster functions.

Imagine using HTML Layout within Developer Studio to create a customized front-end used for scheduling a ReportCaster job. In WebFOCUS 7.6.2, you have this ability. If   ReportCaster, the WebFOCUS Web Services Enablement Option that includes ReportCaster Web Services and the Web Services Adapter are licensed, ReportCaster functionality can be performed by writing a WebFOCUS Report against a Master file representing the specific ReportCaster Web Services operation. In the Fall 2004 issue of WebFOCUS Newsletter, (“Adapting to Web Services”) I explain how a Web Service function defined by a Web Services Description Language (WSDL) file is mapped to a Master and Access file.

The full documentation of ReportCaster Web Services and the Web Services adapter can be found in the ReportCaster Web Services manual.

Let’s go through the process of getting a WebFOCUS Report to schedule a ReportCaster job.

The first thing we need is the WSDL file for the Schedule Web Service. The URL to this WSDL file is http://<machine name:port>/rcaster/services/ScheduleService?wsdl. This file should be saved locally because it will have to be modified before it is consumed with the Web Services adapter.

ReportCaster Web Services make use of Abstract Type definitions. We use this type to define distribution, time information, and task type. There are six distribution types (e.g., e-mail, printer); seven time information types (e.g., run once, daily), and five task types (e.g., WebFOCUS Report from Application, WebFOCUS Report from Managed Reporting).

The following is the WSDL definition for the Distribution type:

- <complexType abstract="true" name="Distribution">
  <sequence />
  </complexType>

The following is the WSDL definition for the Schedule object.

- <complexType name="Schedule">
- <sequence>
  <element name="active" type="xsd:boolean" />
  <element name="compressedReport" type="xsd:boolean" />
  <element name="deleteJobAfterRun" type="xsd:boolean" />
  <element name="description" nillable="true" type="soapenc:string" />
  <element name="distribution" nillable="true" type="tns1:Distribution" />
  <element name="id" nillable="true" type="soapenc:string" />
  <element name="notification" nillable="true" type="tns1:Notification" />
  <element name="owner" nillable="true" type="soapenc:string" />
  <element name="priority" type="xsd:int" />
  <element name="taskList" nillable="true" type="impl:ArrayOf_tns1_Task" />
  <element name="timeInfo" nillable="true" type="tns1:TimeInfo" />
  <element name="traceType" type="xsd:int" />
  </sequence>
  </complexType>

Notice that there is one element for distribution, one for Time Information, and one for the Task type. The various distribution, time information, and task types are not explicitly defined in the Schedule object itself. The different types are defined elsewhere in the WSDL file.

The following is the definition for DistributionEmail:

- <complexType name="DistributionEmail">
- <complexContent>
- <extension base="tns1:Distribution">
- <sequence>
  <element name="destination" nillable="true" type="tns1:Destination" />
  <element name="inlineMessage" nillable="true" type="soapenc:string" />
  <element name="inlineTaskIndex" type="xsd:int" />
  <element name="mailFrom" nillable="true" type="soapenc:string" />
  <element name="mailReplyAddress" nillable="true" type="soapenc:string" />
  <element name="mailServerName" nillable="true" type="soapenc:string" />
  <element name="mailSubject" nillable="true" type="soapenc:string" />
  <element name="sendingReportAsAttachment" type="xsd:boolean" />
  <element name="zipFileName" nillable="true" type="soapenc:string" />
  <element name="zipResult" type="xsd:boolean" />
  </sequence>
  </extension>
  </complexContent>

 

Notice that this complex type makes reference to the abstract type of distribution. The Web Services Adapter does not support abstract types. Web Services consumers like .NET and Apache Axis do support abstract types, and the ReportCaster WSDL file can be consumed as is.

The ReportCaster WSDL file would have to be modified to explicitly point to the specific distribution, time information, and task types before performing Create Synonym. Also, all element definitions within the WSDL file that are defined as soapenc:string should be changed to xsd:string.

Let’s modify the WSDL file so that we will be able to create a Master file so that the addSchedule function will be able to schedule a ReportCaster job, which distributes the report via e-mail, have the job run once, and have it run a WebFOCUS report from the application environment.

Below is the modified Schedule object definition:

- <complexType name="Schedule">
- <sequence>
  <element name="active" type="xsd:boolean" />
  <element name="compressedReport" type="xsd:boolean" />
  <element name="deleteJobAfterRun" type="xsd:boolean" />
  <element name="description" nillable="true" type="xsd:string" />
  <element name="distributionEmail" nillable="true" type="tns1:DistributionEmail" />
  <element name="id" nillable="true" type="xsd:string" />
  <element name="notification" nillable="true" type="tns1:Notification" />
  <element name="owner" nillable="true" type="xsd:string" />
  <element name="priority" type="xsd:int" />
  <element name="taskListWFServerProcedure" nillable="true" type="impl:ArrayOf_tns1_TaskWFServerProcedure" />
  <element name="timeInfoOnce" nillable="true" type="tns1:TimeInfoOnce" />
  <element name="traceType" type="xsd:int" />
  </sequence>
  </complexType>

 Below is the modified Task array type:

- <complexType name="ArrayOf_tns1_TaskWFServerProcedure">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:TaskWFServerProcedure[]" />
  </restriction>
  </complexContent>
  </complexType>

Chapter 3 of the ReportCaster Web Services manual documents all the different distribution, time information and task types that can be used with each element’s meaning.

We are now ready for the Create Synonym process. Create a Web Service connection pointing to the location of the modified WSDL file (e.g., file://c:/ibi/apps/ReportCaster/ScheduleServiceModified.wsdl). Perform Create Synonym against this new connection and choose the addSchedule function. Before clicking the Create Synonym button, make sure that Validate and Make Unique is checked. This ensures the uniqueness of the fieldnames when an element name appears more than once in the WSDL file.

We now have to modify the Aliases for the GROUP definition for distribution, time information and task within the Master to match the original element name defined in the WSDL.

In our example, change the following lines:

GROUP=DISTRIBUTIONEMAIL, ALIAS=distributionEmail, ELEMENTS=10, $

GROUP=TASKLISTWFSERVERPROCEDURE, ALIAS=taskListWFServerProcedure, ELEMENTS=1, $

GROUP=TIMEINFOONCE, ALIAS=timeInfoOnce, ELEMENTS=2, $

To the following:

 GROUP=DISTRIBUTIONEMAIL, ALIAS=distribution, ELEMENTS=10, $

GROUP=TASKLISTWFSERVERPROCEDURE, ALIAS=taskList, ELEMENTS=1, $

GROUP=TIMEINFOONCE, ALIAS=timeInfo, ELEMENTS=2, $

The following is a sample WebFOCUS report that schedules a ReportCaster job:

TABLE FILE ADDSCHEDULE
PRINT
ADDSCHEDULERETURN
WHERE PASSWORD EQ ''
WHERE USER1 EQ 'admin'
WHERE ACTIVE EQ 'true'
WHERE DELETEJOBAFTERRUN EQ 'false'
WHERE DESCRIPTION EQ 'Carinst WebFOCUS Report'
WHERE SINGLEADDRESS EQ 'efrem_litwin@ibi.com'
WHERE TYPE EQ 'SINGLE_ADDRESS'
WHERE MAILFROM EQ 'efrem_litwin@ibi.com'
WHERE MAILREPLYADDRESS EQ 'efrem_litwin@ibi.com'
WHERE MAILSERVERNAME EQ 'ibismtp.ibi.com'
WHERE MAILSUBJECT EQ 'ReportCaster Job - Carinst'
WHERE SENDINGREPORTASATTACHMENT EQ 'false'
WHERE TYPE1 EQ 'INACTIVE'
WHERE OWNER EQ 'admin'
WHERE DESCRIPTION1 EQ 'Task1 - RC Test Fex'
WHERE REPORTNAME EQ 'Carinst Report'
WHERE EXECID EQ 'EDA'
WHERE EXECPASSWORD EQ 'EDA'
WHERE NAME1 EQ 'COUNTRY'
WHERE VALUE EQ 'ENGLAND'
WHERE PROCEDURENAME1 EQ 'Carinst'
WHERE SENDFORMAT EQ 'HTML'
WHERE SERVERNAME1 EQ 'EDASERVE'
WHERE STARTTIME EQ DT(2007-08-02 21:45:00)
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
END

All start and end time input values must be converted to Universal Time. This is how ReportCaster stores this information. So, in the example above, 2007-08-02 21:45:00 is really 2007-08-02 17:45:00 in New York City.

The Master file can be modified to give more meaningful fieldnames. Also, the DESCRIPTION attribute can be added to each field to give longer descriptions on the meaning of each field, which can be used at the WebFOCUS Report development time.

Once a Master and Access file is created in one environment, it can be used in other installations. The URL in the Access file and connection string would need to be changed to point to the correct environment. Also, newer ReportCaster releases might have additional elements from previous releases. Therefore, Master and Access files created in newer releases might not work in an older release.

Since the same alias name can be used more than once in a Master as long as the fieldnames are different, a Master can be created which encompasses all distribution, time information, and task types for the addSchedule operation. This can be done by just adding them to the Schedule object definition in the WSDL file and adding additional Task Array WSDL definitions using the one in this article as a basis.