Skip to main content

Example: Example Production

Tutorial.ExampleProduction consists of a single Business Operation. The operation is defined by the class Tutorial.ExampleOperation. The operation handles request messages of type Ens.StringRequestOpens in a new tab and returns a response of type Ens.StringResponseOpens in a new tab.

Here is the code for the message handling method in Tutorial.ExampleOperation:


Method Test(pRequest As Ens.StringRequest, 
Output pResponse As Ens.StringResponse) As %Status
{
 Set pResponse=##class(Ens.StringResponse).%New()
 if (pRequest.StringValue="")
 {
   Set pResponse.StringValue="ERROR"
   Set tSC=$$$ERROR($$$GeneralError, "Test error case")
 }
 else
 {
   Set pResponse.StringValue="OK"
   Set tSC=$$$OK
 }
 $$$LOGINFO(pResponse.StringValue)
 Return tSC
}

The method does the following:

  • Handles messages of type Ens.StringRequestOpens in a new tab that are sent to TestOperation.

  • Creates a response message of type Ens.StringResponseOpens in a new tab.

  • If the value of the request message's StringValue property is null, it creates an error message and stores it in tSC and assigns “ERROR” to the response message's StringValue property.

  • If the value of the request message's StringValue property is not null, it assigns an OK status to tSC and “OK” to the response message's StringValue property.

  • Uses $$$LOGINFO to add an entry to the Event Log. The entry will be type “info” and its Text is the response message's StringValue property.

The next several pages present example callback methods for testing this Production and its Business Operation.

FeedbackOpens in a new tab