INT009A - 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 RPG program. Integrator Studio also generates an RPG and an RDML example.
1. Using the LANSA Editor, create a new process iiiPRO08 – SOAP Server and an RDMLX function iiiFN09 – Get Employees Server, belonging to it (without using a template). 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).
2. The next steps describe the logic that is in your function. 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 iiiEmployeeServer 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. 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 7B. 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.