Hello folks, today we see how to consume an Integration service from Visualizer Reference Architecture Web form application.
Follow the below step:
- First configure the fabric URL. In order to do so go to "Edit" in top menu. Then go to "Visualizer Preferences" and then "Fabric". Enter the Fabric URL and then "validate"
- Now link the MicroApp with FabricApp in which the service has been created. To do that go to "Data & Services" tab in visualizer then go to "Link to Existing App". Then on the desired app click "Associate"
- In order to consume refer the sample code that is provided from Fabric console. Go to "Integration Service" tab in fabric console of the application and click on your service and click on "sample code" icon as shown in the image.
- Now copy the sample code for the service and its operation and paste in your controller/module code.
- Below is the form controller code for invoking the Integration Service and logging the response in console:onPostShow: function(){var serviceName = "MyTestService2";var integrationObj = KNYMobileFabric.getIntegrationService(serviceName);//Code to invoke parent integration service should be present to use below code.var operationName = "MyTestOperation2";var data= {};//{"countryname": "United States"}; //sample valuevar headers= {};integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);function operationSuccess(res){// code for success call backconsole.log('operationSuccess:');console.log(res);}function operationFailure(res){// code for failure call backconsole.log('operationFailure:');console.log(res);}},
- Check the output in the console window of browser