Anchor | ||||
---|---|---|---|---|
|
...
- Perform steps 1 to 3 mentioned in the Web Service Configuration for Fetching Data using the GET Method.
- In the Create New Data Source page, configure the property fields in the Mandatory Configuration tab as follows:
- Connection Name: This is a non-editable field and displays the unique name provided by you for the connection. For example, WSCONNECTIONPOST.
- Data Source Name: Provide a unique data source name. For example, WEBSERVICEPOSTING.
- Relative part of the URL: Provide the relative URL. For example, ShreeFinancials/rest/finance/addProduct.
- Communication App ID: Select the Rest POST JSON Gateway option in this field. For more details on this field, refer the Field Descriptions.
- In the Response Data Mapping panel, provide inputs in the fields as follows:
Column Root: Provide the hierarchical path to the element that contains the JSON array of data from the Web service response. For example, for the finance Web service, the JSON response is as follows:
Code Block language text { "STATUSCODE": "SUCCESS" }
Therefore, the root element will be $ as the response is starting from the root path.Value Select Expression: For the finance Web service, provide the value select expression as follows:
Code Block language text #getStatus({'status':'STATUSCODE','Message':'MESSAGE'})#
As we are posting data to the finance Web service, we are expecting a response status and a detailed message from the Web service. The fields in which the status and the message are passed will differ for each Web service. Hence, use the getStatus() method to define the status and message fields for Canvas to parse the Web service response. Here, 'status' and 'Message' are the JSON field names in which the actual field names 'STATUSCODE' and 'MESSAGE' are sent respectively.
View Column Id: Provide the value STATUS in this field.
Info In the case of posting to a Web service, the value STATUS in the View Column Id field is an indication to Canvas to identify the value select expression to parse the posting Web service status response. Therefore, the value provided in this field must always be STATUS, irrespective of the Web service being configured.
Unlike the GET or POST method to fetch data, we do not have to provide the View Column Id value – STATUS in the Column ID field in App Designer or the View Item ID field on the Create View Definition screen. This is because we are posting data to the Web service through a form. We configure only the status response from the Web service as the value select expression for posting data.
In the Request JSON Configuration field, specify the JSON as shown in the following screen shot:
Refer Passing Data as Header Parameter in Request to get more information on sending data as header parameter to the request.Note - The query param concept applies only to Web services using the GET HTTP method.
- When the POST method is used for Web service configuration, the payload is sent in the body of the request in JSON format.
Code Block language text { "productDesc": "$form.productDesc", "productCode": "$form.productCode", "transactionAmount": "$form.transactionAmount", "gcif": "$form.gcif", "userId": "$form.userId", "transactionRefNo": "$form.transactionRefNo" }
Here, $form.<fieldname> indicates that these fields will be available in the forms generated through Request Modeler for the data to be published to the Web service.
The following screen shot shows the Request JSON Configuration field with the JSON configuration:
When you hover over the confirmed JSON, the following icons can display:
: To enable or disable a field in the JSON model condition.
: To add a field in the JSON model condition.
: To delete the JSON Model condition from the Request JSON Configuration field.
In the Create New Data Source screen, configure the property fields in the Additional Configuration tab as follows:- Service Type: The field is auto-populated with the POST option when the Rest POST JSON Gateway option is selected in the Communication App ID field. For more information on this field, refer the Field Descriptions.
- Instruction Class: This field is auto-populated with the default Java instruction class com.intellectdesign.canvas.defaultviews.DefaultRestServiceInstruction. For more information on this field, refer the Field Descriptions.
- Click Save.
Once the data source is successfully created for the connection, you can do any of one of the following:
Create a request in Request Modeler to auto generate a form for publishing data to the Web service.
OR
Create a form in form designer, create a request by mapping the correct Web service data source and map the Request Model ID to the form. When you are designing the form ensure that the form item IDs exactly match with the Web service field names. For more information, refer Configuring Request Modeler.
...