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:
public web
variables
string vInput ; Input parameter from URL
string vOutput ; Output content to be returned
endvariables
; --- 1 --- get input parameter
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 !
return(0)
end
- Compile
- 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!