Rest Services In MDriven
No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{message|Write the content here to display this box}}
<message>Write the content here to display this box</message>
'''REST Services''' are services executed by connecting to a URL that defines operation and parameters and returns an answer – not seldom as JSON objects.
'''REST Services''' are services executed by connecting to a URL that defines operation and parameters and returns an answer – not seldom as JSON objects.


Line 5: Line 5:


=== '''Calling Existing REST Services''' ===
=== '''Calling Existing REST Services''' ===
MDriven supports a couple of EAL operators to manage REST services. All operators reside on the [[selfVM]] variable which is available only in the ViewModel context.
MDriven supports a couple of EAL operators to manage REST services. All operators reside on the [[Documentation:SelfVM|selfVM]] variable which is available only in the ViewModel context.
  ''selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)''
  ''selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)''
Read: [[OCLOperators RestGet]]
'''Read:''' [[Documentation:OCLOperators RestGet|OCLOperators RestGet]]
  ''selfVM.RestPost(targeturl,user,pwd,optionalnestingwithheadersAndUploadValues)''
  ''selfVM.RestPost(targeturl,user,pwd,optionalnestingwithheadersAndUploadValues)''
Read: [[OCLOperators RestPost]]
'''Read:''' [[Documentation:OCLOperators RestPost|OCLOperators RestPost]]
  ''selfVM.RestDownload(targeturl,user,pwd,optionalnestingwithheaders)''
  ''selfVM.RestDownload(targeturl,user,pwd,optionalnestingwithheaders)''
Read: [[OCLOperators RestDownload]]
'''Read:''' [[Documentation:OCLOperators RestDownload|OCLOperators RestDownload]]


'''Note!''' ''optionalnestingwithheaders'' is the '''name''' of the blue ViewModel class in the example below (as an OCL String).
'''Note!''' ''optionalnestingwithheaders'' is the '''name''' of the blue ViewModel class in the example below (as an OCL String).
Line 19: Line 19:
The action '''GetExporttest''' retrieves data by converting another ViewModel to XML - it stores it in the variable <code>vText</code>.
The action '''GetExporttest''' retrieves data by converting another ViewModel to XML - it stores it in the variable <code>vText</code>.


The next action invokes RestPost to send that data to a URL address; it also says it should look at the nesting named 'Xml'. In this nesting, we have the STRINGCONTENT (see also [[OCLOperators RestPost]]) which gets its content from the vText variable. We also add the header Authorization with a bearer token to get access from the receiving service.
The next action invokes RestPost to send that data to a URL address; it also says it should look at the nesting named 'Xml'. In this nesting, we have the STRINGCONTENT ('''see also''' [[Documentation:OCLOperators RestPost|OCLOperators RestPost]]) which gets its content from the vText variable. We also add the header Authorization with a bearer token to get access from the receiving service.


'''See also''': [[Documentation:Exposing Ourselves as a REST Service|Exposing Ourselves as a REST Service]]
'''See also''': [[Documentation:Exposing Ourselves as a REST Service|Exposing Ourselves as a REST Service]]
[[Category:Rest]]
[[Category:Rest]]
[[Category:Advanced]]
[[Category:Advanced]]
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}

Latest revision as of 05:52, 6 February 2025

This page was created by Alexandra on 2016-12-22. Last edited by Stephanie@mdriven.net on 2025-02-06.

REST Services are services executed by connecting to a URL that defines operation and parameters and returns an answer – not seldom as JSON objects.

You must set the tagged value RestAllowed on the ViewModels you want to allow Rest access to.

Calling Existing REST Services

MDriven supports a couple of EAL operators to manage REST services. All operators reside on the selfVM variable which is available only in the ViewModel context.

selfVM.RestGet(targeturl,user,pwd,optionalnestingwithheaders)

Read: OCLOperators RestGet

selfVM.RestPost(targeturl,user,pwd,optionalnestingwithheadersAndUploadValues)

Read: OCLOperators RestPost

selfVM.RestDownload(targeturl,user,pwd,optionalnestingwithheaders)

Read: OCLOperators RestDownload

Note! optionalnestingwithheaders is the name of the blue ViewModel class in the example below (as an OCL String).

Example

2018-05-29 10h31 45.png

The action GetExporttest retrieves data by converting another ViewModel to XML - it stores it in the variable vText.

The next action invokes RestPost to send that data to a URL address; it also says it should look at the nesting named 'Xml'. In this nesting, we have the STRINGCONTENT (see also OCLOperators RestPost) which gets its content from the vText variable. We also add the header Authorization with a bearer token to get access from the receiving service.

See also: Exposing Ourselves as a REST Service