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

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
ColinP
Posts: 6
Joined: Wed May 02, 2018 7:40 pm
Location: UK

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

Post by ColinP » Mon Jan 21, 2019 11:31 pm

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

ColinP
Posts: 6
Joined: Wed May 02, 2018 7:40 pm
Location: UK

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

Post by ColinP » Wed Jan 23, 2019 3:14 am

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.

Post Reply