Advantco Salesforce APEX AddOn –exposing APEX REST services in 3 steps

Introduction

The Salesforce adapter for SAP PI/PO or CPI generates schemas for multiple Salesforce objects, this simply integration efforts for use cases where there are multiple objects that have to be created in a specific order and where the relationship has to maintain from parent object to child objects. The multiple objects schema eliminates the need for complex BPM or iFlows as all the logics can be specify in the message mapping. The adapter takes care of the processing of the different object types in the order that was generated with the schema. As an example, one can create a multiple schema with the Order and OrderItem objects. This schema allows one to map a payload that has Order and OrderItem records. At runtime the adapter will send first Order records to Salesforce, wait for response and then process OrderItem objects. This means there are multiple API calls to process the payload.Advantco Salesforce APEX AddOn_exposing APEX REST services in 3 steps_Pic1

 

However, in certain use cases, one may want to send the whole payload to Salesforce, this reduces the number of API calls and improves the processing time as the adapter will send the whole mapped payload to Salesforce in one single API call. To do this, one has to expose a APEX REST service on Salesforce side. As this means custom development, Advantco created a Workbench that can expose any number of objects as a REST endpoint without the need to write a single line of APEX code.

APEX Add-on Workbench

The main feature of the Workbench is to generate the APEX class that is required to expose a REST service. This REST service can have multiple objects and can be easily created by dragging an object from the list and drop it in the selection box. The Workbench handles both standard as well custom objects.
Step 1: Select objects to expose the functionality of the REST service.
In this example, we want to expose a REST service to create an Order with OrderItems in Salesforce.

Advantco Salesforce APEX AddOn –exposing APEX REST services in 3 steps

Step 2: Generate the APEX class
Once we select the objects that we want to expose with the REST service, we generate the APEX class. We provide the URI for the new REST service as part of the generation step.

Advantco Salesforce APEX AddOn –exposing APEX REST services in 3 steps

Step 3: Deploy the APEX class
Deploying the new APE class will make the new REST available for Salesforce adapter to consume this new REST service from SAP PI/PO or CPI.

Advantco Salesforce APEX AddOn –exposing APEX REST services in 3 steps

Consume the APEX REST service from SAP CPI.

The new APEX REST service can be easily consume from SAP CPI. Create an iFlow with a receiver channel using the Salesforce adapter type. Select ‘Apex REST Web Service‘ as Message Protocol.

Advantco Salesforce APEX AddOn_exposing APEX REST services in 3 steps_Pic5

Specify the endpoint of the REST service.

Advantco Salesforce APEX AddOn_exposing APEX REST services in 3 steps_Pic6

Consume the APEX REST service from SAP PI/PO.

Select ‘Apex REST Web Service‘ as Message Protocol and specify the REST service endpoint.

Advantco Salesforce APEX AddOn_exposing APEX REST services in 3 steps_Pic7

Summary

Implementing custom APEX REST service is a cumbersome task, requiring APEX skillset and is subject to constant maintenance effort. With the APEX Add-on, at Advantco we try to make this process a simple 3 steps process that can generate REST services that is based on the standard or custom objects defined in the Salesforce instance.


Please reach out to our sales team at sales@advantco.com if you have any questions.