Implement custom integration logic via Apex by using the Apex Type Provider. This provider requires an Apex Integration Developer to implement a custom Apex adapter interface.
Use a custom Apex adapter to:
Include and use integration parameters in adapter implementations such as timeouts, credentials, and path.
Generate and transform requests and responses via Omnistudio Integration Procedures or Extract, Transform, Load (ETL) libraries.
Enable asynchronous interaction pattern.
Enable request and response logging by implementing a specific Apex interface.
Handle errors, and integrate with fallout rules.
To configure the callout settings for Apex Type Provider, see Configuration Steps.
Integration Adapter Implementation
Implement the industriesintegrationfwk.ProcessIntegrationProvider Apex interface. Use the industriesintegrationfwk.ApexProviderAttr class to define and access the attribute values in the integration provider definition.
1global with sharing class DROSampleOrderAdapter implements industriesintegrationfwk.ProcessIntegrationProvider{23 // Named credential attribute4 private static final String MOCK_CALLOUT_NAMED_CREDENTIAL = 'callout:DROOrderInterfaceNamedCred';5 private final static Integer TIMEOUT = 10000; // Request timeout in milliseconds, or can be defined on Integration Definition as an Attribute678 private static final industriesintegrationfwk.ApexProviderAttr NAMED_CRED_ATTR = new industriesintegrationfwk.ApexProviderAttr('Named Credential', 9 'Named_Credential', 'DROOrderInterfaceNamedCred', true, 'String');10 private static final industriesintegrationfwk.ApexProviderAttr ENDPOINT_ATTR = new industriesintegrationfwk.ApexProviderAttr('Endpoint URI', 11 'Endpoint_URI', '/v1/orderitems/', true, 'String');121314 /**15 * @param requestGuid Request Globally Unique Identifier (GUID) provided by the client16 * @param inputRecordId Input Record ID — value is taken from Fulfillment Step > Fulfillment Step Source > Source Line Item17 * @param payload Payload to be passed to the Provider Class (empty in DRO)18 * @param attributes Map of configuration attributes19 * @return IntegrationCalloutResponse Response sent to the client20 */21 global static industriesintegrationfwk.IntegrationCalloutResponse executeCallout(String requestGuid, String inputRecordId, String payload, Map<String, Object>attributes){22 // create request23 String msgBody = '{\"message\":\"Hello\",'24 + '\n\"requestGuid\":\"' + requestGuid + '\",\n'25 + '\n\"inputRecordId\":\"' + inputRecordId + '\",\n'26 + '\n\"payload\":\"' + payload + '\"}'27 ;2829 String endpointUri = (String)attributes.get('Endpoint_URI');3031 // Make a call32 HttpResponse response = makeCallout(endpointUri, msgBody);33 // process response and pass details to the DRO Callout Step processor by using IntegrationCalloutResponse(isSuccess, ResponseCode, ErrorMessage)3435 industriesintegrationfwk.IntegrationCalloutResponse integrationCalloutResponse = handleResponse(response); 3637 return integrationCalloutResponse;38}3940 // define configurable attriobutes 41 global static List<industriesintegrationfwk.ApexProviderAttr>getProviderAttributes(){42 List<industriesintegrationfwk.ApexProviderAttr>defaults = new List<industriesintegrationfwk.ApexProviderAttr>();43 defaults.add(NAMED_CRED_ATTR);44 defaults.add(ENDPOINT_ATTR);45 // add any attributes such as endpoint, timeout, interface, and params46 // ...47 return defaults;48}4950 // Call Mock Service API.51 private static HttpResponse makeCallout(String endpointUri, String msgBody){5253 // Construct the request object54 String endPoint = MOCK_CALLOUT_NAMED_CREDENTIAL + endpointUri;55 HttpRequest request = new HttpRequest();56 request.setMethod('POST');57 request.setHeader('Content-Type', 'application/json');58 request.setHeader('Accept', 'application/json');59 request.setEndpoint(endPoint);60 request.setTimeout(TIMEOUT);61 request.setBody(msgBody);6263 // Send request64 HttpResponse response = new Http().send(request);65 return response;66}67}
Error Handling
This sample shows how to pass errors from response to orchestration via the IntegrationResponse interface in the Apex provider implementation. See ProcessIntegrationProvider Interface.
1public static industriesintegrationfwk.IntegrationCalloutResponse handleResponse(HttpResponse response){23 industriesintegrationfwk.IntegrationCalloutResponse integrationCalloutResponse;45 Map<String, Object>responseGroup = getResponseGroupAfterCallout(response);67 if(response.getStatusCode() == 200)8{9 // SUCCESS10 integrationCalloutResponse = new industriesintegrationfwk.IntegrationCalloutResponse(true);11 integrationCalloutResponse.setResponseCode(response.getStatusCode());12 integrationCalloutResponse.setReturnValue(responseGroup);1314}else{15 //FAILURE - pass error to DRO Fallout Handling to apply Retry Policies16 integrationCalloutResponse = new industriesintegrationfwk.IntegrationCalloutResponse(false);17 integrationCalloutResponse.setResponseCode(response.getStatusCode());18 integrationCalloutResponse.setReturnValue(responseGroup);19 integrationCalloutResponse.setErrorMessage('Unable to process request.');20}21 return integrationCalloutResponse;22}2324 // Process Response payLoad 25 private static Map<String, Object>getResponseGroupAfterCallout(HttpResponse response){26 Map<String, Object>responseGroup = new Map<String, Object>();27 if(response.getStatusCode() == 200){28 responseGroup.put('isSuccess', true);29}else{30 responseGroup.put('isSuccess', false);31}32 responseGroup.put('response', getResponseMap(response.getBody()));33 return responseGroup;34}3536 // Convert response string into Map 37 private static Map<String,Object>getResponseMap(String responseBody){38 try{39 Map<String,Object>responseBodyMap = (Map<String,Object>)JSON.deserializeUntyped(responseBody);40 return responseBodyMap;41}catch(Exception e){42 Map<String, Object>responseMap = new Map<String,Object>();43 responseMap.put('response', responseBody);44 return responseMap;45}46}
The fulfillment step state changes to Fatally Failed, and the error message is saved in the Execution Message field.
Apex Advanced Interface Implementation
To use advanced features such as logging, the Apex provider must implement the Apex Provider Advanced interface. You must use the HttpBaseProvider client for HTTP requests.
This example shows a sample of the ProcessIntegrationProviderAdvanced Apex interface implementation.
1global with sharing class DFOApexVlocMockWithDelay2implements industriesintegrationfwk.ProcessIntegrationProviderAdvanced{3...4global static industriesintegrationfwk.IntegrationCalloutResponse executeCallout(String requestGuid, String inputRecordId, String payload, Map<String, Object>attributes,5industriesintegrationfwk.HttpBaseProvider httpProvider){6...7String endPoint = MOCK_CALLOUT_NAMED_CREDENTIAL + '/delay/5';8HttpRequest request = new HttpRequest();9request.setMethod('POST');10request.setHeader('Content-Type', 'application/json');11request.setHeader('Accept', 'application/json');12request.setEndpoint(endPoint);13request.setTimeout(TIMEOUT);14request.setBody(msgBody);1516// Send request17//HttpResponse response = httpProvider.httpCallout(request);18HttpResponse response = new Http().send(request);
Integration Definition Configuration
Select the Save the request and response as attachments to the record checkbox for the integration definition to save request and response payloads as attachments to the Integration Provider Execution record. Content publish limits apply when saving request and response payloads as attachments. Use Shield Platform Encryption for secure storage of sensitive information.
Integration Provider execution records are created on every request and associated with the fulfillment step. The referenced object identifier is set to order item or fulfillment order line item ID. SeeIntegrationProviderExecution.
To view the Integration Provider execution records, configure the Fulfillment Step record page to include the Integration Provider Executions related list by using Lightning App Builder. See Lightning App Builder.