generateMsg()

Generates a message from a set of predefined messages in a message file.

Syntax

char * generateMsg(int msgNum, int msgType, char * info,
        int argCount, ...);
  

Parameters

msgNum [in]
specifies the message number (identifier) in the message file.

msgType [in]
is one of the following message types defined in the CxMsgFormat class:

  XRD_WARNING
  
   
  XRD_ERROR
  
   
  XRD_FATAL
  
   
  XRD_INFO 
  
   
  XRD_TRACE 
  

info [in]
is an informational value, such as the name of the class for which the IBM WebSphere business integration system generated the message.

argCount [in]
is an integer that specifies the number of parameters within the message text (optional).

... [in]
is an optional list of message parameters for the message text, separated by commas. Each parameter is a char * value.

Return values

A pointer to the generated message.

Notes

The generateMsg() method allocates memory to store a generated message. When the connector has logged the message, it should call the freeMemory() method to release the allocated memory. This method is a member of the connector framework class JToCPPVeneer. The syntax of the call is void freeMemory(char * mem), where mem is the memory allocated by generateMsg(). See the sample code below for an example of how to call this method.

If the msgtype parameter is invalid, the message generation process does not validate it. The generateMsg() method displays an alert that the message is not in the message file.

Note:
The generateMsg() method is also available in the GenGlobals class. It is provided in the BOHandlerCPP class for access to message-file messages from within the business object handler.

Examples

char * msg;
  ret_code = connect_to_app(userName, password);
  // Message 1100 - Failed to connect to application
  if (ret_code == -1) {
     msg = generateMsg(1100, CxMsgFormat::XRD_ERROR, NULL, 0, NULL);
     logMsg(msg);
     JToCPPVeneer::getTheHandlerStuff()->freeMemory(msg);
     return BON_FAIL; 
  }
  

Copyright IBM Corp. 1997, 2003