Writing Applications with the Natural Wrapper

This document covers the following topics:


Writing RPC Clients for RPC-ACI Bridge in Natural

Prerequisites

The parameters of the IDL program must contain an A field with a length of at least 254 bytes or of unlimited length. You need to have dynamic data types in your IDL. You must use COMPR=2 (send buffer completion).

Writing a Natural Client

Start of instruction setTo write a Natural client

  1. Use CALLNAT for the Natural RPC client.

  2. Provide a context for EntireX as described under Interface RPC-CNTX for the Natural RPC Client Programmer below. See the Natural documentation for details.

The RPC-ACI Bridge reports errors on the ACI side or the Broker for ACI with Natural error 998 (Internal error details). The details contain the error number followed by a description. Use Natural subroutine USR2030N to retrieve error class, error code and description. The error class for the RPC-ACI Bridge is 1018. See Message Class 1018 - EntireX RPC-ACI Bridge.

For error handling, use for example (the declarations of the variables are omitted):

ON ERROR
  IF *ERROR-NR = 998 THEN
    CALLNAT 'USR2030N' ERR-PARM(*) OCC RESPONSE
    IF OCC > 0 THEN
      MOVE SUBSTRING(ERR-PARM(1), 1, 8) to #ERR-CODE
      MOVE SUBSTRING(ERR-PARM(1), 10) to #ERR-DETAIL
      WRITE #ERR-CODE
      WRITE #ERR-DETAIL (AL=79)
      ESCAPE ROUTINE
    END-IF
  END-IF
END-ERROR

Interface RPC-CNTX for the Natural RPC Client Programmer

API RPC-CNTX is used for providing a context for RPC client applications. RPC-CNTX combines the functionality of several APIs and is available in library SYSTEM. There is no need for extra preparations such as setting a STEPLIB or copying APIs from SYSEXT to user libraries.

RPC-CNTX makes the following interfaces from SYSEXT obsolete: USR1071N, (USR4371N), USR6304N, USR2007N, USR4008, USR4009, USR2071N.

For the usage of RPC-CNTX refer to the test programs generated by the Natural Wrapper, see Sample Generation Result for the Client Side.

For further information refer to the Natural RPC documentation.

Returning Application Errors from an RPC Server to an RPC Client

Application error codes enable the RPC server to return customer-invented errors back to the RPC client in a standardized way without defining an error code field in the IDL file.

USR4012N from Natural library SYSEXT may be used to enforce Natural error NAT1999 on the Natural RPC server and to pass back the provided error text to the RPC client.

Example

 /* Application Error
 COMPRESS "ERROR: " #ERR-TEXT INTO #LOG-TEXT
 /* Send back Application Error to Client
 CALLNAT 'USR4012N' USING #ERR-TEXT

For more information:

Interfaces (APIs) Available in SYSEXT

The Natural library SYSEXT provides APIs for RPC programming. Log on to the library SYSEXT and enter MENU. To list only RPC-related APIs, enter the keyword RPC. To make these APIs available, make the necessary STEPLIP settings or copy the APIs from SYSEXT to user libraries. For more information, refer to the API documentation provided by SYSEXT.

Interface Comment
USR1071N Set user ID and password for RPC
USR2007N Set/get RPC default server information.
USR2015N EBCDIC or ASCII translation table for Natural RPC.
USR2032N Support of commit for CLOSE CONVERSATION.
USR2035N Support of SSL.
USR2071N Support of EntireX Security on client side.
USR2072N Support of EntireX Security on server side.
USR2073N Ping or terminate an RPC server.
USR2074N Set new password for NSC user in RPC context.
USR2075N Terminate EntireX Broker service.
USR4008N Set library for RPC execution.
USR4009N Set parameters for EntireX.
USR4010N Retrieve runtime settings of server.
USR4012N Support of application error.
USR4371N Set user ID and ETID for RPC.
USR6304N Set/get reliable state for RPC execution.
USR6305N Commit/rollback reliable RPC message(s).
USR6306N Status of UOWs of current EntireX Broker user.
etc.