Previous Topic

Next Topic

Book Contents

Book Index

Example: Receiving and analyzing a Control-M/EM API response using XML Generator Classes

The following code snippet uses the emapiXMLgenerator classes to analyze the response of Control-M/EM to a Job Create request.

NOTE: The full working program can be found on the DVD.

import java.util.Enumeration;

import java.io.IOException;

import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;

import com.bmc.ctm.bpi.tester.emapiXMLgenerator.*;

...

Receive the EMResponseXML string from the response queue

...

String orderID = null;

Response myResponse = new Response( EMResponseXML );

System.out.println( "EM response to Job Create request:" );

// Check the return status of our request

String respStatus = myResponse.getStatus();

System.out.println( " STATUS = " + respStatus );

if (respStatus.equalsIgnoreCase( Response.GENERAL_STATUS_OK ))

{

// If our request was successful, retrieve the details of the response

Enumeration respData = myResponse.getResponseData();

while (respData.hasMoreElements())

{

JobCreateOrderForceResponseData jobData =

(JobCreateOrderForceResponseData) respData.nextElement();

if (jobData.isStatusOk())

{

System.out.println (" JOBNAME = " + jobData.getJobName());

System.out.println (" MEMNAME = " + jobData.getMemName());

orderID = jobData.getOrderId();

System.out.println (" ORDERID = " + orderID);

}

else

{

System.out.println (" MAJOR = " + jobData.getMajorCode());

System.out.println (" MINOR = " + jobData.getMinorCode());

System.out.println (" SEVERITY = " + jobData.getSeverity());

System.out.println (" MESSAGE = " + jobData.getErrorMessage());

}

}

}

// If the return status is not OK, print return codes and error message

else if (respStatus.equalsIgnoreCase( Response.GENERAL_STATUS_ERROR ))

{

System.out.println (" MAJOR = " + myResponse.getMajorCode());

System.out.println (" MINOR = " + myResponse.getMinorCode());

System.out.println (" SEVERITY = " + myResponse.getSeverity());

System.out.println (" MESSAGE = " + myResponse.getMessage());

}

else if (respStatus.equalsIgnoreCase( Response.SYSTEM_ERROR ))

{

System.out.println (" DESCRIPTION = " +

myResponse.getSystemErrorDescription());

System.out.println (" EXCEPTION = " +

myResponse.getSystemExceptionText());

System.out.println (" STACKTRACE = " +

myResponse.getSystemExceptionStackTrace());

}

else

{

System.out.println (" MESSAGE = " + myResponse.getMessage());

Parent Topic

Control-M Messaging API administration