How to make a simple RESTful web service in Uniface.
From my blog: The Uniface Universe
After building both SOAP and RESTful webservices in Uniface my opinion is: use REST when you can, SOAP when you must. This article explains why: REST vs. SOAP ? The Right WebService
Not many people know how easy it is to build RESTful webservices in Uniface. Because you do not need special statements or features there is no information on it in the documentation.
Here are the steps for building a (very) basic RESTful webservice:
- Create a new DSP component RESTBLOG
- Remove all code from all triggers (especially Set State)
- Add a dummy entity
- Enter this sample code into the Execute trigger:
; — 1 — get input parameter
string vInput ; Input parameter from URL
string vOutput ; Output content to be returned
getitem/id vInput, $webinfo(“INPUT”), “name”
; — 2 — create output based on input
; you can do anything here
vOutput = “Hello %%vInput%%%, I am the output”
; — 3 — fill the output channel
$webinfo(“output”) = vOutput
; And we are done !
- Test using a URL like http://localhost:8086/uniface/wrd/RESTBLOG?name=Theo
- Congratulations, you have just build your first Uniface RESTful web service!
NB: We did NOTHING in the Layout Editor!