ServiceAPI Methods
In this section, the ServiceAPI class methods are presented in alphabetical order.
Syntax
getInputParameter(parameter_name)
Description
Use this method to retrieve input value based on parameter defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
parameter_name  | 
 Specifies the name of the input parameter (as a string).  | 
Returns
Any.
Values can be the following:
Boolean
Date
Document
Integer
JSON Object
Number
Number Array
String
String Array
Time
Example
&state = %This.ServiceAPI.getInputParameter("conditions");
Syntax
getInputRow(index)
Description
Use this method to retrieve the specified input message row based on the index.
Parameters
Parameter  | 
Description  | 
|---|---|
index  | 
 Specifies the index (as a Number) of the row to retrieve.  | 
Returns
The specified message row.
Example
&jsNoteBook = %This.ServiceAPI.getInputRow (1).getParameter("notebook");
Syntax
getLocationURL(URI_index)
Description
Use this method to create the URL string based on the passed in URI index.
Parameters
Parameter  | 
Description  | 
|---|---|
URI_index  | 
 Specifies the URI index defined on the application service.  | 
Returns
A String; the URL.
Example
%This.ServiceAPI.setLocationTemplateParameter("musicCode", &intValue, True);
This.ServiceAPI.setResponseHeader("Location",%This.ServiceAPI.getLocationURL(1));
Syntax
getOutputContentData()
         
      Description
Use the getOutputContentData method to retrieve the actual content data sent back from the third party for consumer REST call.
Parameters
None.
Returns
A String value.
Example
&RawData = &ServiceAPI.getOuputContentData();
         
      Syntax
getOutputParameter(parameter_name)
Description
Use this method to retrieve output value based on parameter defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
parameter_name  | 
 Specifies the name of the output parameter (as a string).  | 
Returns
Any.
Values can be the following:
Boolean
Date
Document
Integer
JSON Object
Number
Number Array
String
String Array
Time
Example
&state = %This.ServiceAPI.getOutputParameter("conditions");
Syntax
getOutputRow(index)
Description
Use this method to retrieve the specified output message row based on the index.
Parameters
Parameter  | 
Description  | 
|---|---|
index  | 
 Specifies the index (as a Number) of the row to retrieve.  | 
Returns
The specified message row.
Example
%This.ServiceAPI.getOutputRow(1).setParameter("tools", &Inst);
Syntax
getRequestHeaderValue(header_name)
Description
Use this method to retrieve request header value based on header defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
header_name  | 
 Specifies the name of the request header (as a String).  | 
Returns
A String; the value of the request header.
Example
&headervalue = %This.ServiceAPI.getRequestHeaderValue("Accept-Language");
Syntax
getTemplateParameter(parameter_name)
Description
Use this method to retrieve template value based on parameter defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
parameter_name  | 
 Specifies the name of the input parameter (as a string).  | 
Returns
Any.
Values can be the following:
Boolean
Date
Decimal
Integer
String
Time
Array of Any
Example
&state = %This.ServiceAPI.getTemplateParameter("instrument");
Syntax
InsertOutputRow()
Description
Use this method to insert an empty message row.
Parameters
None.
Returns
None.
Example
%This.ServiceAPI.InsertOutputRow();
%This.ServiceAPI.OutputRows [1].setParameter("numPlayers", 3);
%This.ServiceAPI.OutputRows [1].setParameter("instrument", &value);
Syntax
setInputParameter(parameter_name,parameter_type)
Description
Use this method to set input value based on parameter defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
parameter_name  | 
 Specifies the name of the input parameter (as a string).  | 
parameter_type  | 
 Specifies the type of the input parameter (as Any). Values can be the following: 
  | 
Returns
None.
Example
%This.ServiceAPI.setInputParameter("conditions", &state);
Syntax
setLocationTemplateParameter(template_name,template_type,template_collection)
Description
Use this method to set the variable value defined on the base template defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
template_name  | 
 Specifies the name of the template parameter (as a String).  | 
template_type  | 
 Specifies the type of the template parameter (as Any). Values can be the following: 
  | 
template_collection  | 
 Specifies whether the template parameter is a collection or not. True if the template parameter is a collection; false otherwise.  | 
Returns
None.
Example
%This.ServiceAPI.setLocationTemplateParameter("instrument", "drums", False);
%This.ServiceAPI.setLocationTemplateParameter("timein", %Time, False);
Syntax
setOutputParameter(parameter_name,parameter_type)
Description
Use this method to set output value based on parameter defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
parameter_name  | 
 Specifies the name of the output parameter (as a string).  | 
parameter_type  | 
 Specifies the type of the output parameter (as Any). Values can be the following: 
  | 
Returns
None.
Example
import PTCBAPPLSVCDEFN:ApplicationServiceBase;
class STUDENT extends PTCBAPPLSVCDEFN:ApplicationServiceBase
   method invokeService();
   
end-class;
method invokeService
   /+ Extends/implements PTCBAPPLSVCDEFN:ApplicationServiceBase.invokeService +/
   Local JsonArray &jsStudentArray;
   Local array of string &stud;
   &jsStudentArray = CreateJsonArray();
   &jsStudentArray.AddElement(&stud [1]);
   &jsStudentArray.AddElement(&stud [2]);
   %This.ServiceAPI.setOutputParameter("student", &jsStudentArray);
end-method;
Syntax
setOverrideURL(&URL)
         
      Description
Use the setOverrideURL method to override the URL sent to the third party for consumer REST call.
Parameters
| 
                            Parameter  | 
                        
                            Description  | 
                     
|---|---|
| 
                            &URL  | 
                        
                            Specifies the URL as a String.  | 
                     
Returns
None.
Example
&ServiceAPI.SetOverrideURL("URL");
         
      Syntax
setResponseHeader(header_name,header_value)
Description
Use this method to set the response header value based on header defined on the application service.
Parameters
Parameter  | 
Description  | 
|---|---|
header_name  | 
 Specifies the name of the response header (as a String).  | 
header_value  | 
 Specifies the value of the response header (as a String).  | 
Returns
None.
Example
%This.ServiceAPI.setResponseHeader("Language", “eng”);