These are the steps necessary
to create a JSON REST API. To change from JSON to XML is easy, but I will focus
on JSON.
• Create or identify the record that you will be
using. I created four records. Three records that will be used for employee
data. X_ERROR will be used to place error messages coming from the API.
• Create documents from the records. Each of the
records created will be used to create a document.
These are the documents that were created based on
records
• Create additional documents to be used in your http
GET and POST requests. The documents created from records are not enough to get
all the information that you need. In this case I want to retrieve the employee
id, name, all her email addresses, and all her phone numbers. To accomplish
that, I need create another document. This additional document will use the
documents that were created from records.
•
Create messages based on documents. I will only create two messages. One to be
used as template and the other that will contain the employee data and error
messages (if any)
•
Create Service. One service needs to be created in which different Service
Operations can be added
• Create Service Operation within Service. Once the
Service has been saved, Service Operations can be added. In this case I am
adding the GET Service Operation. A couple of things to note here. One is the
URL that will be used to get the data and the other is the word
"nothing" The template needs to have something there.
"nothing" is there to identify that nothing will be passed on the
template.
• Add Security to Service Operation. This security is a permission list that will access to this Service Operation. Since this is just a demo, I am granting access to PTPT1000 but on a production environment, this will be decided by your favorite security administrator.
• Create application package. The code below is used
to populate the data into the message that will be sent to the user.
• Update Service Operation Handlers with the
application package. The Service Operation needs to have a request handler.
• Test. Remember thing 1 from the Service Operation
image, that is the URL that will be used for testing. In my PUM image, the URL
is http://hostname:8000/PSIGW/RESTListeningConnector/PSFT_HR/X_GET_EMPLOYEE_DATA.v1/nothing
Final thoughts. If everything went well, you will have see a nice empty JSON result. If you want to see some data, you can do some insert statements on the three employee records and refresh your page. This URL with the security that was added will always return the PS data because that will be default user. If you scroll back to the Service Operation Image, you will see on the top right that there is a checkbox for User/Password Required. For this demo, that was left unchecked but in practice you should enable at least Basic Authentication and SSL.
Thanks,
Manoranjan