JSMDirect Example

LANSA Integrator

JSMDirect Example

Loads Open/Close Example Service. The SERVICE_LOAD command will be modified, as this function is invoked via JSMDirect and will pass all POST data. The JSM_CLOSE will cause the last JSMRESPONSE byteArray to be sent back to JSMDirect to write to STDOUT.

********** Beginning of RDML commands **********  
FUNCTION   OPTIONS(*DIRECT)
**********                                                 
DEFINE     FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(20)           
DEFINE     FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(255)          
**********                                                 
********** 'Open service'                                  
**********                                                 
USE        BUILTIN(JSM_OPEN) TO_GET(#JSMSTS #JSMMSG)       
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)   
**********                                                 
********** 'JSMDirect will modify the SERVICE_LOAD command 
********** and pass the POST data on with the command      
**********                                                  
USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_LOAD SERVICE(EX 
           AMPLE1)') TO_GET(#JSMSTS #JSMMSG)                       
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)           
**********                                                         
********** 'Closing the JSM, will cause last JSMRESPONSE byteArray 
********** to be sent back to JSMDirect cgi-bin program'           
**********                                                         
USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)              
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)           
**********                                                         
**********                                                         
********** SUB ROUTINES                                            
**********                                                         
SUBROUTINE NAME(CHECK) PARMS((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVE  
           D))                                                      
**********                                                          
IF         COND('#JSMSTS *NE OK')                                   
**********                                                          
********** 'Closing the JSM, will cause any JSMRESPONSE byteArray   
********** to be sent back to JSMDirect cgi-bin program'            
**********                                                          
USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)               
**********                                                          
RETURN                                                              
**********                                                          
ENDIF
********** 
ENDROUTINE