Page 1 of 1

How do I specify the return status code passed back to a RESTful web service

Posted: Sat Jan 19, 2019 3:09 am
by ColinP
We have just had a jsmproxy/jsmdirect server set up to enable our business partners to send us data via a RESTful web service.
I have written a new function in RDMLX using JSMX functions to process the JSON data that is sent via the web service.

The basic outline of the function is:-

Code: Select all

USE BUILTIN(JSMX_OPEN) TO_GET(#gblJSMSts #gblJSMStM #gblJSMHnd)
#gblJSMCmd := 'SERVICE_LOAD  SERVICE(HTTPInboundJSONBindService) SERVICE_CONTENT(*HTTP)
 TRACE(*YES)'
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#gblJSMHnd #gblJSMCmd) TO_GET(#gblJSMSts #gblJSMStM)
#gblJSMCmd := 'BIND TYPE(*INBOUND) SERVICE(MYSERVICENAME) SERVICE_EXCHANGE(*FIELD)'
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#gblJSMHnd #gblJSMCmd) TO_GET(#gblJSMSts #gblJSMStM)
BEGIN_LOOP
#gblJSMCmd := 'GET FRAGMENT(MYFRAGMENTNAME) SERVICE_EXCHANGE(*FIELD)'
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#gblJSMHnd #gblJSMCmd) TO_GET(#gblJSMSts #gblJSMStM)
IF (#gblJSMSts *EQ NOFRAGMENT)
* End of response
LEAVE
ENDIF
… save the date
END_LOOP
#gblJSMCmd := 'SERVICE_UNLOAD'
* * * SERVICE_UNLOAD not needed??? USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#gblJSMHnd #gblJSMCmd) TO_GET(#gblJSMSts #gblJSMStM)
USE BUILTIN(JSMX_CLOSE) WITH_ARGS(#gblJSMHnd) TO_GET(#gblJSMSts #gblJSMStM)

*????? now do I now set the HTTP return status code to 200 if I processed the data correctly ??? rather than 600 [JMSDirect Message] that is currently being returned (with a "JSMDirect transaction did not complete" html message)

RETURN
The function works fine and adds the information from the JSON data into my new database files.
My question is how do I specify the return status code that is passed back to the web service? E.g. I think I need to pass back status “200” to indicate the data has been received and processed correctly. However, the function is returning status “600 JSMDirect Message” and some html saying, “JSMDirect transaction did not complete”.

Thanks in advance
Colin

Re: How do I specify the return status code passed back to a RESTful web service

Posted: Tue Jan 22, 2019 3:23 am
by ColinP
This has now been solved by Theo from Lansa Support.

The code need is:

Code: Select all

SEND RESPONSE(*EMPTY)