Salesforce

How to use parameters in Asynchronous Requests

« Go Back

Information

 
TitleHow to use parameters in Asynchronous Requests
URL Name20785
Article Number000156346
EnvironmentProduct: OpenEdge
Version: All Progress/OpenEdge Versions
OS: All Supported Platforms
Other: AppServer, SOAP Webservices
Question/Problem Description
How to use parameters in Asynchronous Requests ?
Why does an Asynchronous request raise error "Mismatched number of parameters passed to routine  (3234)" for the event-procedure ?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Asynchronous requests handle the OUTPUT and INPUT-OUTPUT parameters differently than synchronous requests. After the asynchronous request is finished, the EVENT-PROCEDURE defined in the RUN statement is executed.

Therefore the OUTPUT and INPUT-OUTPUT parameters that are defined in the RUN statement are passed to the EVENT-PROCEDURE and not to the RUN statement.

Asynchronous requests must define the parameters in the same way that they are sent in the RUN statements, as is true for synchronous requests.

The way to define parameters in the EVENT-PROCEDURE is different and this must be changed. Parameters defined as INPUT parameters in the asynchronous request are not defined in the EVENT-PROCEDURE, and the parameters defined as OUTPUT or INPUT-OUTPUT in the asynchronous request must be defined as INPUT parameters in the EVENT-PROCEDURE.

The following is an example of how run and define parameters in asynchronous requests:
 
DEFINE VARIABLE hServer  AS HANDLE    NO-UNDO.
DEFINE VARIABLE hProcess AS HANDLE    NO-UNDO.
DEFINE VARIABLE param1   AS CHARACTER NO-UNDO INITIAL "Initial Value".
DEFINE VARIABLE param2   AS CHARACTER NO-UNDO INITIAL "Initial Value".
DEFINE VARIABLE param3   AS CHARACTER NO-UNDO INITIAL "Initial Value".
DEFINE VARIABLE lServer  AS LOGICAL   NO-UNDO.

CREATE SERVER hServer.
ASSIGN lServer = hServer:CONNECT("-AppService asbroker1 -H SomeHost -S 5162") NO-ERROR.

IF lServer = FALSE THEN    
  ASSIGN hServer = SESSION:HANDLE.

IF VALID-HANDLE(hServer) = FALSE THEN    
DO:        
  MESSAGE "No server connected.." VIEW-AS ALERT-BOX.        
  RETURN ERROR.    
END.

RUN async1.p ASYNCHRONOUS              
             SET hProcess              
             EVENT-PROCEDURE "endasync" IN THIS-PROCEDURE             
             ON SERVER hServer 
  (  INPUT param1, 
     OUTPUT param2, 
     INPUT-OUTPUT param3 ).

DO WHILE NOT hProcess:COMPLETE:
 
  PROCESS EVENTS.
 
  IF hProcess:COMPLETE THEN
    MESSAGE "param1: " param1 SKIP        
        "param2: " param2 SKIP        
        "param3: " param3        
      VIEW-AS ALERT-BOX INFORMATION.
  ELSE /* Async result not ready, so do something else. */
    MESSAGE "Not yet ..." VIEW-AS ALERT-BOX INFORMATION.
 
END.


PROCEDURE endasync:

  DEFINE INPUT PARAMETER value2 AS CHARACTER NO-UNDO.
  DEFINE INPUT PARAMETER value3 AS CHARACTER NO-UNDO.

  ASSIGN
    param2 = "Value Changed in event-procedure"
    param3 = value3
    .

END PROCEDURE.



/********************************************************/
/* Procedure async1.p to be run as asynchronous request */
/********************************************************/

DEFINE INPUT   PARAMETER param1 AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER param2 AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER param3 AS CHARACTER NO-UNDO.

PAUSE 10.
ASSIGN param3 = "Value changed in Async procedure".
Workaround
Notes
Keyword Phrase
Last Modified Date4/6/2018 12:27 PM

Powered by