Page 1 of 1

How do I pass a parameter into a jsmproxy RESTful web service via the URL?

Posted: Mon Jan 21, 2019 11:31 pm
by ColinP
Hi Lansa Forum
Sorry; another question about Lansa Integrator RESTful web services.

I have written an RDMLX function that uses Lansa Integrator to process some data sent to us from a business partner in JSON format via a RESTful web service. They can use a URL in the format:-

Code: Select all

https://MYSERVER.com/cgi-bin/jsmproxy.exe?MYFUNCTION
However, I also need to receive an authentication token from the customer in the URL query string so I can validate the URL is from a valid customer.
I have tried a few examples such as:-

Code: Select all

https://MYSERVER.com/cgi-bin/jsmproxy.exe?MYFUNCTION&auth=123
https://MYSERVER.com/cgi-bin/jsmproxy.exe?MYFUNCTION+auth=123
But I get a response from jsmproxy:-

Code: Select all

Version: 13.2.0
Usage: /cgi-bin/jsmproxy.exe?service+...
JSMProxy (c) the LANSA Group. All rights reserved
What is the correct URL syntax to pass parameters to a jsmproxy service?
Also; what Lansa Integrator command do I use to retrieve the parameters from the URL?

Thanks in advance
Colin

Re: How do I pass a parameter into a jsmproxy RESTful web service via the URL?

Posted: Wed Jan 23, 2019 3:14 am
by ColinP
This has now been answered by Karen from Lansa support.

The URL syntax is:-

Code: Select all

https://MYSERVER.com/cgi-bin/jsmproxy.exe?MYFUNCTION+auth(123)
Then:-
- define field #auth in the web service function
- add BIND(*FIELD) SERVICE_EXCHANGE(*FIELD) to the HTTPInboundJSONBindService service load command:-

Code: Select all

DEFINE FIELD(#auth) TYPE(*char) LENGTH(100)

#gblJSMCmd := SERVICE_LOAD
#gblJSMCmd += ' SERVICE(HTTPInboundJSONBindService)'
#gblJSMCmd += ' SERVICE_CONTENT(*HTTP)'
#gblJSMCmd += ' BIND(*FIELD)'
#gblJSMCmd += ' SERVICE_EXCHANGE(*FIELD)'
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#gblJSMHnd #gblJSMCmd) TO_GET(#gblJSMSts #gblJSMStM)
The field #auth will then contain "123" in this example.