Home » scheduleReport

scheduleReport

Description

Schedules report with the given parameter

Attributes

FieldTypeDescriptionRequired
param0ClientReportParamTrue

 

ClientReportParam

FieldTypeDescriptionRequired
nameStringA unique label to identify the client reportTrue
valueStringTrue

Samples

Java



import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;

import com.zedo.zapi.ZEDOAPIStub;
import com.zedo.zapi.ZEDOAPIStub.ScheduleReport;
import com.zedo.zapi.ZEDOAPIStub.*;
import com.zedo.zapi.zclients.config.Config;

public class ScheduleReportRunner {
 private static Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS zzz");

 private static void scheduleReportRun() {

 try {

 ZEDOAPIStub stub = new ZEDOAPIStub("http://api.zedo.com/v8/?wsdl&java"); 
 stub._getServiceClient().addStringHeader(new QName("http://api.zedo.com", "user", "zedoapi"),"example@example.com");
 stub._getServiceClient().addStringHeader(new QName("http://api.zedo.com", "password", "zedoapi"),"password");
 stub._getServiceClient().addStringHeader(new QName("http://api.zedo.com", "network", "zedoapi"),"525");
 stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10 * 60 * 1000);
 
 ScheduleReport entityReport = new ScheduleReport();
 Map paramMap = new HashMap();
 paramMap.put("name", "report Name");
 paramMap.put("format", "html");
 paramMap.put("startDate", "11/16/2015");
 paramMap.put("endDate", "12/16/2015");
 paramMap.put("Campaign ID","1944858");
 
 ClientReportParam[] params = new ClientReportParam[paramMap.size()];
 Set keys = paramMap.keySet();
 Iterator it = keys.iterator();
 int j = 0;
 while(it.hasNext()){
 params[j] = new ClientReportParam();
 String key =(String) it.next();
 params[j].setName(key);
 params[j].setValue((String)paramMap.get(key));
 ++j;
 }
 
 entityReport.setReportParam(params);

 Thread.sleep(1000);
 ClientReportStatus reportStatus = stub.scheduleReport(entityReport).get_return();
 System.out.println(formatter.format(new Date()) + " STATUS: ");
 System.out.print(" StatusCode: ");

 switch (reportStatus.getStatusCode()) {
 case 0x0:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (DONE)");
 break;
 case 0x100:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (DONE_WITH_ERRORS)");
 break;
 case 0x200:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (ACCEPTED)");
 break;
 case 0x300:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (ESTIMATING)");
 break;
 case 0x400:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (GENERATING)");
 break;
 default:
 System.out.printf("%x", reportStatus.getStatusCode());
 System.out.println(" (INTERNAL_ERROR)");
 }

 System.out.println(" SchedulerKey: " + reportStatus.getSchedulerKey());
 System.out.println(" Estimation: " + reportStatus.getEstimation());
 

 for (int i = 0; i < 62; i++) {

 System.out.println(formatter.format(new Date()) + " WORK OF getSchedulerTaskStatus(): ");
 GetSchedulerTaskStatus taskStatus = new GetSchedulerTaskStatus();
 taskStatus.setSchedulerKey(reportStatus.getSchedulerKey());
 ClientReportStatus report = stub.getSchedulerTaskStatus(taskStatus).get_return();

 if (report.getStatusCode() == 0x0) {
 System.out.print(" StatusCode: ");
 System.out.printf("%x", report.getStatusCode());
 System.out.println(" (DONE)");
 System.out.println(" SchedulerKey: " + report.getSchedulerKey());
 System.out.println(" Estimation: " + report.getEstimation());

 
 GetReport rep = new GetReport();
 rep.setKey(reportStatus.getSchedulerKey());
 ClientReportResult reportResult = stub.getReport(rep).get_return();

 Thread.sleep(1000);
 GetReportUrl repUrl = new GetReportUrl();
 repUrl.setKey(reportStatus.getSchedulerKey());
 String reportUrl = stub.getReportUrl(repUrl).get_return();
 System.out.println("REPORT URL: " + reportUrl);
 Thread.sleep(1000);
 System.out.println(formatter.format(new Date()) + " PRINT REPORT: ");
 for (ClientReportResultItem item : reportResult.getItems()){
 System.out.println(item.getBody());
 }
 break;
 } else if (report.getStatusCode() == 0x100) {
 System.out.print(" StatusCode: ");
 System.out.printf("%x", report.getStatusCode());
 System.out.println(" (DONE_WITH_ERRORS)");
 System.out.println(" SchedulerKey: " + report.getSchedulerKey());
 System.out.println(" Estimation: " + report.getEstimation());

 GetReport rep = new GetReport();
 rep.setKey(reportStatus.getSchedulerKey());
 ClientReportResult reportResult = stub.getReport(rep).get_return();

 for (ClientReportResultItem resultItem : reportResult.getItems()) {
 throw new Exception("REPORT WAS DONE WITH ERRORS Body: " + resultItem.getBody());
 }

 } else if (report.getStatusCode() == 0x200 || report.getStatusCode() == 0x300 || report.getStatusCode() == 0x400) {
 System.out.print(" StatusCode: ");
 System.out.printf("%x", report.getStatusCode());
 if (report.getStatusCode() == 0x200) {
 System.out.println(" (ACCEPTED)");
 } else if (report.getStatusCode() == 0x300) {
 System.out.println(" (ESTIMATING)");
 } else if (report.getStatusCode() == 0x400) {
 System.out.println(" (GENERATING)");
 }
 System.out.println(" SchedulerKey: " + report.getSchedulerKey());
 System.out.println(" Estimation: " + report.getEstimation());

 if (i == 60) {
 throw new Exception("TIME IS OUT!");
 }
 System.out.println(" PLEASE WAIT!");
 Thread.sleep(10 * 1000);
 continue;
 } else {
 System.out.print(" StatusCode: ");
 System.out.printf("%x", report.getStatusCode());
 System.out.println(" (INTERNAL_ERROR)");
 System.out.println(" SchedulerKey: " + report.getSchedulerKey());
 System.out.println(" Estimation: " + report.getEstimation());
 throw new Exception("INTERNAL ERROR");
 }
 System.out.println(formatter.format(new Date()) + " STATUS: OK ");
 }

 } catch (Exception e) {
 System.err.println("Exception: " + e.getMessage());
 e.printStackTrace();
 }
 }

 public static void main(String[] args) {
 ScheduleReportRunner.scheduleReportRun();
 }

 
 }

PHP

include_once './zlib/ZEDOAPI.php';
        
        /**
         *Create Client Stub
         */
        $config = Array();
        $config['location'] = 'http://api.zedo.com/v8/?wsdl&php';               //URL of the SOAP server to send the request to
        $config['exceptions'] = true;                                                                                                   //Enable Exception Handling
        
        $stub = new ZEDOAPI($config);
        
        $header = Array();
        $header[0] = new SoapHeader('http://api.zedo.com','user', 'example@example.com');
        $header[1] = new SoapHeader('http://api.zedo.com','password', 'password');
        $header[2] = new SoapHeader('http://api.zedo.com','network','525');
        $header[3] = new SoapHeader('http://api.zedo.com','callinfo','zapiCall');
        
        $stub->__setSoapHeaders($header);
        
        /**
         *Define Call Parameters 
         */
        $report_parameters = Array();
        $report_parameters[0] = new ClientReportParam("name", "Vishal API Constraint");
        $report_parameters[1] = new ClientReportParam("format", "html");
        $report_parameters[2] = new ClientReportParam("startDate", "05/01/2010");
        $report_parameters[3] = new ClientReportParam("endDate", "06/01/2010");
        $report_parameters[4] = new ClientReportParam("Campaign Name", "Time Changes");
        //Pass Report Constraints if any in $report_parameters. For example : $report_parameters[4] = new ClientReportParam("Campaign Name", "SampleCampaign");
        
        $param = new scheduleReport($report_parameters);
        
        /**
         *Execute API Call 
         */
        try {
                $response = $stub->scheduleReport($param);
        }catch (SoapFault $ex) {
         var_dump($ex->faultcode, $ex->faultstring, $ex->detail);
                echo "SCHEDULE REPORT FAILED\n";
            die();
        }
        
        /**
         * Response
         */
        $tmp = new scheduleReportResponse($response);
        $clientReportStatus = $tmp->return->return;
        
        switch ($clientReportStatus->statusCode) {
                case 0x0:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "DONE";
                        break;
                case 0x100:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "DONE WITH ERRORS";
                break;
                case 0x200:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "ACCEPTED";
                        break;
                case 0x300:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "ESTIMATING";
                        break;
                case 0x400:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "GENERATING";
                        break;
                default:
                        echo "\nStatus : ".  $clientReportStatus->statusCode . " - " . "INTERNAL ERROR";
                        break;  
        }
        
        echo "\nScheduler Key : ".  $clientReportStatus->schedulerKey;
        echo "\nEstimation : ".  $clientReportStatus->estimation;
        
        for ($i = 0; $i < 60; $i++) {
                        $taskStatusParam = new getSchedulerTaskStatus($clientReportStatus->schedulerKey);
                        $res = $stub->getSchedulerTaskStatus($taskStatusParam);
                        
                        $tmp = new getSchedulerTaskStatusResponse($res);
                        $reportStatus = $tmp->return->return;
                                                                
                        if($reportStatus->statusCode == 0x0) {
                                echo "\nStatus : ".  $reportStatus->statusCode . " - " . "DONE";
                                echo "\nScheduler Key : ".  $reportStatus->schedulerKey;
                                echo "\nEstimation : ".  $reportStatus->estimation;
                                
                                $report = new getReport($reportStatus->schedulerKey, null);
                        
                                sleep(3);       
                                $reportResult = $stub->getReport($report);
                                $tmp = new getReportResponse($reportResult);
                                $reportResult = $tmp->return->return;
                                
                                sleep(1);
                                $reportUrl = new getReportUrl($reportStatus->schedulerKey, null);
                                
                                try {
                                        $urlResponse = $stub->getReportUrl($reportUrl);
                                } catch (Exception $e) {
                                        echo 'ERROR: '.  $e->getMessage().  "\n";
                                        echo "GET REPORT URL FAILED\n";
                                die();
                                }
                                
                                $url = new getReportUrlResponse($urlResponse);
                                
                                echo "\nREPORT URL : ".  $url->return->return;
                                echo "\nPRINT REPORT : ";
                                
                                echo $reportResult->items->body;
                                break;
                        }
                        else if($reportStatus->statusCode == 0x100) {
                                echo "\nStatus : ".  $reportStatus->statusCode . " - " . "DONE_WITH_ERRORS";
                                echo "\nScheduler Key : ".  $reportStatus->schedulerKey;
                                echo "\nEstimation : ".  $reportStatus->estimation;
                                
                                $report = new getReport($reportStatus->schedulerKey, null);
                                
                                try {
                                        $reportResult = $stub->report=$report;
                                } catch (Exception $e) {
                                        echo 'ERROR: '.  $e->getMessage().  "\n";
                                        echo "GET REPORT URL FAILED\n";
                                die();
                                }
                                
                                $tmp = new getReportResponse($reportResult);
                                $reportResult = $tmp->return;
        
                                echo "\nREPORT WAS DONE WITH ERRORS - Body : ";
                                echo $reportResult->items->body;        
                                break;
                        }
                        else if($reportStatus->statusCode == 0x200 || $reportStatus->statusCode == 0x300 || $reportStatus->statusCode == 0x400) {
                                if($reportStatus->statusCode == 0x200)
                                        echo "\nACCEPTED";
                                else if($reportStatus->statusCode == 0x300)
                                        echo "\nESTIMATING";
                                else if($reportStatus->statusCode == 0x400)
                                        echo "\nGENERATING";
                                        
                                echo "\nScheduler Key : ".  $reportStatus->schedulerKey;
                                echo "\nEstimation : ".  $reportStatus->estimation;
                                
                                if($i==60) echo "TIME IS OUT";
                                
                                echo "PLEASE WAIT";
                                sleep(10);
                                continue;
                        }
                        else {
                                echo "\nStatus : ".  $reportStatus->statusCode . " - " . "INTERNAL ERROR";
                                echo "\nScheduler Key : ".  $reportStatus->schedulerKey;
                                echo "\nEstimation : ".  $reportStatus->estimation;
                        }
                        echo "STATUS : OK";
        }
        

SOAP

Request

POST /axis2/services/ZEDOAPI?wsdl HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="urn:getSchedulerTaskStatus"
User-Agent: Axis2
Host: dev08.juhu.zedo.com:2001
Transfer-Encoding: chunked
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<zedoapi:user xmlns:zedoapi="http://api.zedo.com">example@example.com</zedoapi:user>
<zedoapi:password xmlns:zedoapi="http://api.zedo.com">password</zedoapi:password>
<zedoapi:network xmlns:zedoapi="http://api.zedo.com">525</zedoapi:network>
</soapenv:Header>
<soapenv:Body>
<ns5:getSchedulerTaskStatus xmlns:ns5="http://zapi.zedo.com">
<ns5:schedulerKey>1642254251</ns5:schedulerKey>
</ns5:getSchedulerTaskStatus>
</soapenv:Body>
</soapenv:Envelope>

Response


HTTP/1.1 200 OK
Date: Thu, 21 Jan 2016 07:00:52 GMT
Server: Simple-Server/1.1
Transfer-Encoding: chunked
Content-Type: application/soap+xml; charset=UTF-8; action="urn:getReportResponse"
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:getReportResponse xmlns:ns="http://zapi.zedo.com">
<ns:return xmlns:ax21="http://base.zedo.com/xsd" xmlns:ax22="http://util.zedo.com/xsd" xmlns:ax25="http://soap.reportengine.zedo.com/xsd" xmlns:ax24="http://client.api.zedo.com/xsd" type="com.zedo.reportengine.soap.ClientReportResult">
<ax25:items type="com.zedo.reportengine.soap.ClientReportResultItem">
<ax25:body>Error while processing the data-request</ax25:body>
<ax25:bodyContent>html</ax25:bodyContent>
<ax25:encoding>plain</ax25:encoding>
<ax25:fileExt>html</ax25:fileExt>
<ax25:fileName>ZedoReport</ax25:fileName>
<ax25:filePath>
</ax25:filePath>
</ax25:items>
</ns:return>
</ns:getReportResponse>
</soapenv:Body>
</soapenv:Envelope>