import PTCBAPPLSVCDEFN:ApplicationServiceBase; class band extends PTCBAPPLSVCDEFN:ApplicationServiceBase method invokeService(); end-class; method invokeService /+ Extends/implements PTCBAPPLSVCDEFN:ApplicationServiceBase.invokeService +/ Local string &Inst, &httpMethod, &player, &results, &headervalue; Local integer &UriIndex, &code; Local time &timein; Local date &datein; <* Use the %This.ServiceAPI property to read and write parameters and other Application Services metadata. *> &httpMethod = %This.ServiceAPI.HttpMethod; &UriIndex = %This.ServiceAPI.URIIndex; /************************************************************************** ** Use the HttpMethod property and URIIndex to return the HTTP method ** ** and URI index that was invoked for the transaction. ** *************************************************************************/ If &httpMethod = "GET" Then If &UriIndex = 1 Then /******************************************************************* ** Use the getTemplateParameter method to retrieve template value ** ** based on parameter defined on the application service. ** **********************************************************************/ &Inst = %This.ServiceAPI.getTemplateParameter("instrument"); /******************************************************************** ** Use setOutputParameters for single row output. The code is ** ** commented out here as the tutorial will use multi row output. ** *******************************************************************/ <* %This.ServiceAPI.setOutputParameter("numPlayers", 10); %This.ServiceAPI.setOutputParameter("instrument", &Inst); %This.ServiceAPI.setOutputParameter("playdate", %Date); %This.ServiceAPI.setOutputParameter("timeout", &timein); *> /******************************************************************* ** Use insertOutputRow for multi row output. ** ** For this tutorial the output is hardcoded for simplicity. ** *******************************************************************/ %This.ServiceAPI.insertOutputRow(); %This.ServiceAPI.OutputRows [1].setParameter("numPlayers", 10); %This.ServiceAPI.OutputRows [1].setParameter("instrument", &Inst); %This.ServiceAPI.OutputRows [1].setParameter("playdate", Date(20220202)); %This.ServiceAPI.insertOutputRow(); %This.ServiceAPI.OutputRows [2].setParameter("numPlayers", 6); %This.ServiceAPI.OutputRows [2].setParameter("instrument", &Inst); %This.ServiceAPI.OutputRows [2].setParameter("playdate", %Date); /********************************************************************* ** Use the result state property to set the result state. ** ** Results States denote logical conclusion for the service execution. *********************************************************************/ %This.ServiceAPI.ResultState = "SUCCESS - PLAY MUSIC"; End-If; End-If; If &httpMethod = "POST" Then If &UriIndex = 1 Then /************************************************************* ** Use getRequestHeaderValue to retrieve header value based ** ** on header defined on the application service. ** *************************************************************/ &headervalue = %This.ServiceAPI.getRequestHeaderValue("Accept-Language"); /************************************************************* ** Use setResponseHeader to set the response header value ** ** based on header defined on the application service. ** *************************************************************/ %This.ServiceAPI.setResponseHeader("Type", "Woodwind"); /********************************************************************** ** Use the getTemplateParameter method to retrieve template value ** ** based on parameter defined on the application service. ** **********************************************************************/ &Inst = %This.ServiceAPI.getTemplateParameter("instrument"); /********************************************************************** ** Use the InputRows property to get values on the specified row. ** **********************************************************************/ &player = %This.ServiceAPI.InputRows [1].getParameter("player"); &Inst = %This.ServiceAPI.InputRows [1].getParameter("instrument"); &code = %This.ServiceAPI.InputRows [1].getParameter("musicCode"); &player = %This.ServiceAPI.InputRows [2].getParameter("player"); &Inst = %This.ServiceAPI.InputRows [2].getParameter("instrument"); &code = %This.ServiceAPI.InputRows [2].getParameter("musicCode"); /********************************************************************** ** Use the setOutputParameter to set output value based on parameter ** ** defined on the application service. (single row output) ** **********************************************************************/ %This.ServiceAPI.setOutputParameter("results", "Players added"); /********************************************************************* ** Use the result state property to set the result state. ** ** Results States denote logical conclusion for the service execution. *********************************************************************/ %This.ServiceAPI.ResultState = "Success"; End-If; End-If; end-method;