Back to Four Js Website
Four Js Customer Forum
Subscribe for automatic updates:
RSS
Sign in for full access
|
Help
Four Js Development Tools Forum
>
Discussions by product
>
GWS
>
JSON based Web Service
Most recent posts
Pages: [
1
]
« previous
next »
Reply
|
Print
Author
Topic: JSON based Web Service (Read 24778 times)
Anderson P.
Posts: 82
JSON based Web Service
«
on:
May 21, 2014, 02:17:32 pm »
Is it possible to make a JSON based web service in Genero instead of XML?
Reuben B.
Posts: 1116
Re: JSON based Web Service
«
Reply #1 on:
May 21, 2014, 11:51:40 pm »
Yes.
If you are looking for ...
com.HttpServerRequest.readJSONRequest()
com.HttpServiceRequest.sendJSONResponse()
com.HttpRequest.doJSONRequest()
com.HttpResponse.getJSONResponse()
... to match the XML equivalents
com.HttpServerRequest.readXMLRequest()
com.HttpServiceRequest.sendXMLResponse()
com.HttpRequest.doXMLRequest()
com.HttpResponse.getXMLResponse()
... they aren't there. The technique is to use the Text methods
com.HttpServerRequest.readTextRequest()
com.HttpServiceRequest.sendTextResponse()
com.HttpRequest.doTextRequest()
com.HttpResponse.getTextResponse()
and use the JSON objects methods to turn a JSON Object into a string and vice versa.
Perhaps we should add such JSON methods
Reuben
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of
https://4js.com/ask-reuben
Contributor to
https://github.com/FourjsGenero
Anderson P.
Posts: 82
Re: JSON based Web Service
«
Reply #2 on:
May 22, 2014, 01:27:18 pm »
Do you have an example that i can base in?
Anderson P.
Posts: 82
Re: JSON based Web Service
«
Reply #3 on:
May 22, 2014, 02:21:38 pm »
We always used the
com.WebOperation.CreateDocStyle
method to generate a web service using a record attribute, so I'm not quite sure how to use this methods you proposed... Or is there some way i can use this
CreateDocStyle
method to generate an text web service instead of a XML web service?
Laurent G.
Posts: 114
JSON based Web Service
«
Reply #4 on:
May 29, 2014, 06:03:11 pm »
See attached a small sample I used to do basic testing. Some of the business logic functions on the server side might not work properly but this will give you a general ideal on the client/server exchange and you can use this code as a frame/start
For RESTful type of web services, you currently only can manual write them, no code generation tool is available yet
For the JSON part, we have new methods that allow you to map Objects or Arrays to Genero 4gl records.
datasyncServer.4gl
(9.54 KB - downloaded 1711 times.)
datasyncClient.4gl
(4.16 KB - downloaded 1724 times.)
Anderson P.
Posts: 82
Re: JSON based Web Service
«
Reply #5 on:
May 29, 2014, 06:36:36 pm »
Laurent, that was an excellent example. Thank you very much!
Florencia also sent me an example, merging both gave me exactly what i needed.
It is indeed very easy to accomplish a REST web service with JSON in Genero, once you get the right commands.
Thank you for your attention.
Pages: [
1
]
Reply
|
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Discussion
=> Ask Reuben
=> WWDC21
-----------------------------
Discussions by product
-----------------------------
=> Products announcements
=> Genero BDL
=> GWS
=> GAS and GBC
=> GDC
=> Genero Mobile for Android or iOS
=> Genero Studio
=> Reporting tools (GRW, GRE)
-----------------------------
Jobs
-----------------------------
=> Jobs
Powered by SMF 1.1.21
|
SMF © 2015, Simple Machines
Loading...