Step 8 Create the SOAP Server Business Logic

LANSA Integrator

Step 8. Create the SOAP Server Business Logic

INT010A - SOAP Service - Define Server

Before you can test or use your SOAP Server solution, you need to create the business logic that supports it. That is, a function to receive a request with department code and section code parameters and to build the Employee return parameter which contains the requested employee details.

You do not need to concern yourself with the communication details as LANSA Integrator and the SOAP Wizard has generated the files which implement that.

Following is an outline of the code's functionality using the LANSA RDMLX code generated by Integrator Studio as SAMPLE_RDMLX_GETEMPLOYEES.txt. Note that this program could alternatively have been coded as an RDML function or as an ILE RPG program. Integrator Studio also generates an RPG and an RDML example.

1.  The first steps are to create a connection to the JSM server and to load the SOAP Server service. This is accomplished using the JSMX_OPEN Built-In Function and the SERVICE_LOAD service command.

2.  The function opens the service iiiEMPLOYEESERVER and gets the object *OPERATION. It closes with an error if the operation was not GETEMPLOYEES. Bear in mind that you could develop a function to handle more than one SOAP operation. If the GetEmployees service operation was requested, then the processing proceeds.

3.  The program uses the GET PARAMETER service command to retrieve the values that were received for the department code and the section code. You will remember that in Step 5. Map Parameters to Program Variables you mapped these parameters to program variable names, so this call will automatically populate those variables.

4.  The program tells the SOAP service that it is beginning to build the SOAP response. This is accomplished using the SET PARAMETER(*RETURN) service command.

     The generated code contains a loop since it is aware that the details of each employee will be passed as a fragment. This is the code you need to modify to add the required logic to read employee details from the employee file.

     Remember that the employee id, first name, surname and salary fields are already mapped to the elements of the Employee return parameter.

5.  Finally, the program cleans up by closing the EmployeeServer solution and closing the connection to the JSM server. This will cause the SOAP Server service to send the SOAP response using the data the program has provided.

 

6.  Using the LANSA Editor, create a new process iiiPRO08 – SOAP Server and an RDMLX function iiiFN11 – Get Employees Server, belonging to it. With your iii SOAP Tutorial project open in Integrator Studio, open the generated RDMLX for the EmployeeServer service and copy it into your function (replacing existing code).

As previously, the changes you need to make are very straightforward. Replace the BEGIN_LOOP / END_LOOP with a SELECT/ENDSELECT loop, to retrieve the required fields from the file PSLMST using the correct logical view. Your code should look like the following:

Because of the JSMDirect service entry you created in in Step 7, Part B. Define Service entry, this function will be automatically invoked by JSMDirect when it receives a matching web service request.

The name of the process and function must be the same as that entered in the Direct Service entry.

7.Locate the following code and change the service name using your initials:

* Open SOAP service

Change Field(#JSMXCMD) To('OPEN SERVICE(IIIEMPLOYEESERVER)')

8.  Compile your function. If you are using an IBM i server, check in to the server and compile.