Step 5 Code iiiFN09 Client SET functionality

LANSA Integrator

Step 5. Code iiiFN09 Client SET functionality

INT009 – Department & Employee Client (Optional)

In this step, you will begin to write the RDMLX for the client. The client will send a request document to the server, and receive a list of employees from the service created in INT008. For now, you will code only the creation and sending of the request XML.

The overall structure of the completed client function iiiFN09 will be:

1.  JSMX_OPEN

2.  SERVICE_LOAD HTTPOutboundXMLBindService

3.  BIND outbound

4.  SET DepartmentRequest fragment

5.  WRITE DepartmentRequest fragment

6.  SEND HOST() URI()

7.  BIND service IIIPRO07_SERVICE inbound

8.  GET EMPLOYEELIST fragment

9.  BEGIN_LOOP

         a.  GET EMPLOYEE fragment

         b.  LEAVE if NOFRAGMENT

         c.  GET EMPLOYEESKILLS list

         d.  SELECT LIST

         e.  Add entry WL_EMPSKL

         f.  End SELECT

10.  END_LOOP

11.  SERVICE_UNLOAD

12.  JSMX_CLOSE 

 

1.  Create a new function named iiiFN09 Department & Employee Client belonging to process iiiPRO07 where iii is your unique 3 characters. Create the function without using an application template. Make it an RDMLX enabled function.

2.  In your iii Training project, expand the Client XML Employees Request / samples / RDMLX folder. Copy the code from SAMPLE_RDMLX_OUTBOUND_HTTP.TXT to replace the existing code in function iiiFN09.

3.  Change the GROUP_BY DEPARTMENTREQUEST name to DEPTREQ. The Studio code generator does not currently recognize RDMLX name limits. This is a reference for binding field DEPTMENT.

4.  You need to specify that you are receiving a working list from your wrapper RDML function.

a.   Define working list WL_EMPSKL as it was defined in your wrapper function.

b.  Add a RCV_LIST to the FUNCTION OPTIONS(*DIRECT) to receive working list WL_EMPSKL.

5.  Complete the SEND command. The HOST keyword must point to the web server associated with your JSM Server. The example code below points to an IBM i host. If you are using a local web server and JSM server it could be defined as "localhost". The URI keyword refers to the service being called - IIIFN08_SERVICE. Your code should looksimilar to the following:

* Send HTTP request content

CHANGE FIELD(#JSMXCMD) TO('SEND HOST(10.44.10.236:80) URI(/cgi-bin/jsmdirect?IIIFN08_SERVICE)')

USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)

EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)

     Note: The XMLBind Wizard generates the above code with a URL keyword. This is an error and you should change this keyword to URI as shown in the above code.

6.  Delete the BIND to the inbound.class code, shown below. The response logic will be taken from generated sample RDMLX in the next step

* Bind service to read HTTP response content

CHANGE FIELD(#JSMXCMD) TO('BIND SERVICE( <<<inbound.class>>> ) TYPE(*INBOUND) BINDTRACE(*YES)')

USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)

EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)

Your RDMLX code should currently look like the following:

FUNCTION OPTIONS(*DIRECT) RCV_LIST(#wl_empskl)
* The following fields are used by the xml binding map
* #DEPTMENT
* The following fragments are used by the xml binding map
GROUP_BY NAME(#DEPTREQ) FIELDS(#DEPTMENT)
DEF_LIST NAME(#WL_EMPSKL) FIELDS(#FULLNAME #SKILDESC) TYPE(*WORKING) ENTRYS(9999)
* Open service
USE BUILTIN(JSMX_OPEN) TO_GET(#JSMXSTS #JSMXMSG #JSMXHDLE1)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)

* Load service
CHANGE FIELD(#JSMXCMD) TO('SERVICE_LOAD SERVICE(HTTPOutboundXMLBindService) TRACE(*YES)')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Bind service to create HTTP request content
CHANGE FIELD(#JSMXCMD) TO('BIND SERVICE(IIIPRO07_REQUEST) TYPE(*OUTBOUND)')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Set fragment - DEPARTMENTREQUEST
CHANGE FIELD(#JSMXCMD) TO('SET FRAGMENT(DEPARTMENTREQUEST) SERVICE_EXCHANGE(*FIELD)')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Write content
CHANGE FIELD(#JSMXCMD) TO('WRITE INDENT(*YES) BINDTRACE(*YES)')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)

* Close binding

CHANGE     FIELD(#JSMXCMD) TO('CLOSE')

USE        BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Send HTTP request content
CHANGE FIELD(#JSMXCMD) TO('SEND HOST(10.44.10.236:80) URI(/cgi-bin/jsmdirect?IIIFN08_SERVICE)')
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 #JSMXCMD) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* <<< Inbound binding logic goes here >>>

* Unload service
USE BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMXHDLE1 'SERVICE_UNLOAD') TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Close service
USE BUILTIN(JSMX_CLOSE) WITH_ARGS(#JSMXHDLE1) TO_GET(#JSMXSTS #JSMXMSG)
EXECUTE SUBROUTINE(CHECK) WITH_PARMS(#JSMXSTS #JSMXMSG)
* Check routine
SUBROUTINE NAME(CHECK) PARMS((#JSMXSTS *RECEIVED) (#JSMXMSG *RECEIVED))
IF COND('#JSMXSTS *NE OK')
USE BUILTIN(JSMX_CLOSE) WITH_ARGS(#JSMXHDLE1) TO_GET(#JSMXSTS #JSMXMSG)
MENU MSGTXT('Java service error has occured')
ENDIF
ENDROUTINE
 

7.  Save this function. It is not yet complete. It will be finished in the next step. At this stage, the server function has been sent the XML request document to process.