No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
'''REST services''' are services that are executed by connecting to an URL that defines operation and parameters then it returns an answer – not seldom as JSon objects. | '''REST services''' are services that are executed by connecting to an URL that defines operation and parameters then it returns an answer – not seldom as JSon objects. | ||
===== Calling existing REST services ===== | |||
MDriven supports a couple of EAL operators to manage REST services. All operators reside on the selfVM variable – available only in the ViewModel context. | MDriven supports a couple of EAL operators to manage REST services. All operators reside on the selfVM variable – available only in the ViewModel context. | ||
''selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)'' | ''selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)'' | ||
Line 98: | Line 98: | ||
</ul> | </ul> | ||
</div> | </div> |
Revision as of 19:54, 22 December 2016
REST services are services that are executed by connecting to an URL that defines operation and parameters then it returns an answer – not seldom as JSon objects.
Calling existing REST services
MDriven supports a couple of EAL operators to manage REST services. All operators reside on the selfVM variable – available only in the ViewModel context.
selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)
selfVM.RestPost(targeturl,user,pwd,optionalnestingwithheadersAndUploadValues)
selfVM.RestDownload(targeturl,user,pwd,optionalnestingwithheaders)
There is a also a new helper operator on selfVM:
selfVM.JSonToObjects( «<Type>» , JSonDataInStringFormat)
The selfVM.JSonToObjects creates objects of class Type and matches attributes and association from the json data – and it can create object trees (unclosed graphs) by following names on associations. These few additions enables us to consume Rest services that others expose.
And when it comes to exposing ourselves to others – Turnkey has two new MVC verbs:
MDrivenRest/Get?command=vmname&id=rootobjref
MDrivenRest/Post?command=vmname&id=rootobjref
What they do is that they look for ViewModel named as the command-parameter, if one is found the accessgroups are checked to see if access is allowed. If it is, additional parameters sent in the url are matched against ViewModel variables – and given corresponding values. Then any actions present in the root level of the ViewModel are executed. And then the Get verb packs the viewmodel content as json in the response.
The Post verb looks in the request values after names that match the ViewModel root – if match is found the corresponding value is applied. Then changes – if any – are committed to db. The last thing for post is that it packs the complete ViewModel as json in the response. If there is an error – a string “error: <message>” is returned.
You must set RestAllowed on ViewModels you want to allow Rest access to.
-
calling an existing REST service
exposing ourself as REST service
-
MDriven turnkey app slot
how to expose information as the Rest service?
MDriven Rest/get strategy
-
selfvm
Rest/Get operator
hard-coded objects
-
RestPost operator as a post command
operation execution
vSomeParam adding new parameters