Page 1 of 1

Sending and receiving JSON over HTTP

Posted: Tue Mar 14, 2017 11:40 pm
by HMJust
I hope to get some help with sending and receiving JSON over HTTP.

I am again struggling with the examples and documentation, so I need help to understand how I am supposed to do this.

The task I have is to send some JSON to a RESTful webservice and in the process receive some JSON back.

I know I can use the JSMX commands to load an HTTPSERVICE and send a request with the appropriate headers to the right URL.

But how do I send some JSON with that request?

And how do I receive and parse the JSON that I will receive in the response?

Do I create an Integrator JSON Binding Wizard solution for each of these? And how do I bind them to the HTTP request?

Re: Sending and receiving JSON over HTTP

Posted: Fri Mar 17, 2017 4:58 am
by lansa
The examples for json show how the wams can respond with json. I too am looking for a way to receive a json response to populate a file.

Any help appreciated.

Mark

Re: Sending and receiving JSON over HTTP

Posted: Fri Mar 17, 2017 6:46 pm
by HMJust
I was directed to the JSON samples in the Integrator documentation, as I was told I needed to use those. It means that I have to use Integrator to create an HTTP connection, setting custom headers, and Integrator to bind JSON out and in.

I can get my sample in a repostable format if you are interested. Most importantly, it works :-)

Re: Sending and receiving JSON over HTTP

Posted: Wed Mar 14, 2018 7:56 am
by stevelee67
i know this post is ancient but...

EPC 141070 should make this a whole heckuva lot easier. i've done some playing with it in a non-production VL instance (my "gee steve, what can i do with this? instance)

http://docs.lansa.com/14/en/lansa018/co ... _begin.htm can get you some basic info, and
http://docs.lansa.com/14/en/lansa018/co ... 1_0010.htm will get you more detailed information.

you'll want to get to know these classes:
  • XPRIM_HttpRequest
  • XPRIM_JsonWriter
  • XPRIM_RandomAccessJsonReader
  • XPRIM_JsonObject
i'm no expert on them (yet) but 141070 is the first real thwack that might make it possible to write lansa-native code (no integrator or 3rd party calls) to interact with web services.