I wrote an article about the creation of a REST service that maybe can help you.
https://community.intersystems.com/post/creating-rest-service-iris
You can check the ClassMethod TestPost where a data is received from a post call and is sent finally to a business operation where is transformed into a DynamicObject and parsed to another class. This is the business operation:
Class WSTEST.BO.PersonSaveBO Extends EnsLib.REST.Operation
{
Parameter INVOCATION = "Queue";
Method savePerson(pRequest As WSTEST.Object.PersonSaveRequest, Output pResponse As WSTEST.Object.PersonSaveResponse) As %Status
{
try {
set person = ##class("WSTEST.Object.Person").%New()
#dim request as %DynamicObject = {}.%FromJSON(pRequest.JSON)
set person.PersonId = request.PersonId
set person.Name = request.Name
set person.LastName = request.LastName
set person.Sex = request.Sex
set person.Dob = request.Dob
set tSC = person.%Save()
set pResponse = ##class("WSTEST.Object.PersonSaveResponse").%New()
set pResponse.PersonId = person.PersonId
set pResponse.Name = person.Name
set pResponse.LastName = person.LastName
set pResponse.Sex = person.Sex
set pResponse.Dob = person.Dob
}catch{
Set tSC="Error saving the person"
}
Quit tSC
}
XData MessageMap
{
<MapItems>
<MapItem MessageType="WSTEST.Object.PersonSaveRequest">
<Method>savePerson</Method>
</MapItem>
</MapItems>
}
}- Log in to post comments
.png)
.png)