Sending and receiving JSON over HTTP

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
User avatar
HMJust
Posts: 51
Joined: Wed May 11, 2016 7:23 pm
Contact:

Sending and receiving JSON over HTTP

Post by HMJust » Tue Mar 14, 2017 11:40 pm

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?
I don't know what I am doing, nor how I did it. If it works, luck was involved :geek:

lansa
Posts: 5
Joined: Tue Dec 01, 2015 3:14 am
Location: Denver, Co
Contact:

Re: Sending and receiving JSON over HTTP

Post by lansa » Fri Mar 17, 2017 4:58 am

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
Cheers,

Mark Mason

User avatar
HMJust
Posts: 51
Joined: Wed May 11, 2016 7:23 pm
Contact:

Re: Sending and receiving JSON over HTTP

Post by HMJust » Fri Mar 17, 2017 6:46 pm

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 :-)
I don't know what I am doing, nor how I did it. If it works, luck was involved :geek:

stevelee67
Posts: 6
Joined: Tue Mar 13, 2018 8:25 am

Re: Sending and receiving JSON over HTTP

Post by stevelee67 » Wed Mar 14, 2018 7:56 am

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.

Post Reply