The POST is a name value pair and the response is plain text. So I am using the HttpService OutboundNameValue handler. When I am debugging, after I make the call to the JSM command, I can see the response has been received (by JSMXSTS and JSMXMSG), but I cannot get to it.
The documentation for the OutboundNameValue handler does not mention anything about getting the response back, so I assume I have to use another handler to get it.
I have tried to use the InboundText handler but then I get an error saying "InboundTextHandler: no field list" which from the documentation there should not be any field list. When I try to use a list I get an error saying "Recieve to list is not supported".
Code: Select all
* ====================================================
* Process ........: DSTCPS
* Function .......: DSTC001
* Created on .....: 16/03/22 at 13:45:07
* Template........: JSMXSKEL
* Inputs..........: wk_TCCustId, wk_TCPassword, wk_TCAction, wk_TCReturnUrl
* Outputs.........: wk_TCTransactionId
* ====================================================
function options(*DIRECT)
* WORKING FIELDS
* ====================================================
def_list name(#Content) fields(#STD_TEXT #STD_TEXTL) type(*WORKING) entrys(*MAX)
def_list name(#Response) fields(#STD_TEXT #wk_TCTransactionId) type(*WORKING) entrys(*MAX)
* setup our content list, this will be used as the content for in the request
#STD_TEXT := "custid"
#STD_TEXTL := #wk_TCCustId
add_entry to_list(#Content)
#STD_TEXT := "password"
#STD_TEXTL := #wk_TCPassword
add_entry to_list(#Content)
#STD_TEXT := "action"
#STD_TEXTL := #wk_TCAction
add_entry to_list(#Content)
#STD_TEXT := "returnurl"
#STD_TEXTL := #wk_TCReturnUrl
add_entry to_list(#Content)
* OPEN JSM AND VERIFY STATUS
use builtin(JSMX_OPEN) to_get(#JSMXSTS #JSMXMSG #JSMXHDLE1)
execute subroutine(CHECK_STS) with_parms(#JSMXHDLE1)
* BUILD THE SERVICE LOAD COMMAND
#JSMXCMD := 'SERVICE_LOAD'
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'SERVICE' 'HTTPSERVICE')
use builtin(JSMX_COMMAND) with_args(#JSMXHDLE1 #JSMXCMD) to_get(#JSMXSTS #JSMXMSG)
execute subroutine(CHECK_STS) with_parms(#JSMXHDLE1)
* SEND THE REQUEST
#JSMXCMD := 'SEND'
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'HANDLER' 'OutboundNameValue')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'URI' '/api/token.php') /* not actual URI */
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'HOST' 'sub.domain.com') /* not actual HOST */
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'SECURE' '*YES')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'METHOD' 'POST')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'WAIT' '*YES')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'TIMEOUT' '10000')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'SERVICE_LIST' 'STD_TEXT, STD_TEXTL')
clr_list named(#Response)
use builtin(JSMX_COMMAND) with_args(#JSMXHDLE1 #JSMXCMD) to_get(#JSMXSTS #JSMXMSG)
execute subroutine(CHECK_STS) with_parms(#JSMXCMD)
* RECEIVE THE RESPONSE
#JSMXCMD := 'RECEIVE'
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'HANDLER' 'InboundText')
execute subroutine(KEYWRD) with_parms(#JSMXCMD 'TO' 'wk_TCTransactionID')
* execute subroutine(KEYWRD) with_parms(#JSMXCMD 'SERVICE_LIST' 'STD_TEXT, #wk_TCTransactionId')
use builtin(JSMX_COMMAND) with_args(#JSMXHDLE1 #JSMXCMD) to_get(#JSMXSTS #JSMXMSG)
execute subroutine(CHECK_STS) with_parms(#JSMXCMD)
* exchange the transaction id back to the caller ??? do I need to do this ???
* exchange fields(#wk_TCTransactionId)
* UNLOAD SERVICE
#JSMXCMD := 'SERVICE_UNLOAD'
use builtin(JSMX_COMMAND) with_args(#JSMXHDLE1 #JSMXCMD) to_get(#JSMXSTS #JSMXMSG)
execute subroutine(CHECK_STS) with_parms(#JSMXHDLE1)
* CLOSE JSM AND VERIFY STATUS
use builtin(JSMX_CLOSE) with_args(#JSMXHDLE1) to_get(#JSMXSTS #JSMXMSG)
execute subroutine(CHECK_STS) with_parms(#JSMXHDLE1)
return
* Subroutine to build JSM commands. existing JSM command
*
subroutine name(KEYWRD) parms((#W_CMDX *BOTH) (#W_KEYWRD *RECEIVED) (#W_KEYVAL *RECEIVED))
define field(#W_CMDX) reffld(#JSMXCMD)
define field(#W_KEYWRD) reffld(#STD_TEXT)
define field(#W_KEYVAL) reffld(#STD_TEXTL)
#W_CMDX += ' ' + #W_KEYWRD + '(' + #W_KEYVAL + ')'
endroutine
* Check the status of the JSM command issued
*
subroutine name(CHECK_STS) parms(#W_HDLE)
define field(#MSGDTA) type(*CHAR) length(132)
define field(#W_HDLE) type(*CHAR) length(4)
if cond('#JSMXSTS *NE OK')
#MSGDTA := 'Error Status Code: ' + #JSMXSTS
message msgid(DCM9899) msgf(DC@M01) msgdta(#MSGDTA)
#MSGDTA := 'Error Message: ' + #JSMXMSG
message msgid(DCM9899) msgf(DC@M01) msgdta(#MSGDTA)
endif
endroutine