Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Introduction

SAP Cloud Integration offers Adapter Development Kit (ADK) to develop custom adapters. This blog describes the steps required to implement on-premise connectivity from the custom adapter.

Using ADK on CPI, you can now develop custom adapters which can also connect to on-premise systems.

Pre-requisites:

  1. I assume that you are already experienced with the development of custom adapters using ADK on CPI. Incase if you are new to adapter development using the ADK on CPI, You can get started here

  2. Cloud Connector is already installed and the on-premise system is configured in the cloud connector.


Overview:

The below diagram shows how SAP Cloud Integration establishes the connection to the on-premise system.



Developing the custom adapter:

  1. Download the Generic API and Adapter API bundles from the CPI Tools page.




2.Add the sap.it.public.generic.api.jar and com.sap.it.public.adapter.api.jar file to the resources folder that is in your ADK project.

3.Add the generic.api.jar and adapter.api.jar as a dependency in the pom.xml as shown below:
<dependency>
<groupId>com.sap.it.public</groupId>
<artifactId>generic.api</artifactId>
<version>.X.X/version> <!— Replace with the downloaded version -- >
<scope>system</scope>
<systemPath>
${project.basedir}/src/main/resources/com.sap.it.public.generic.api-2.X.X.jar
</systemPath>
</dependency>
<dependency>
<groupId>com.sap.it.public</groupId>
<artifactId>adapter.api</artifactId>
<version>2.x.x</version> <!— Replace with the downloaded version -- >
<scope>system</scope>
<systemPath>
${project.basedir}/src/main/resources/com.sap.it.public.adapter.api-2.X.X.jar
</systemPath>
</dependency>



4. Add the sap.it.public group ID to the <excludeGroupIds> in the pom.xml.

5. In order to achieve the on-premise connectivity from the receiver adapter, you need to import the below classes on *Producer.java class
import com.sap.it.api.ITApiFactory;
import com.sap.it.api.ccs.adapter.CloudConnectorContext;
import com.sap.it.api.ccs.adapter.CloudConnectorProperties;
import com.sap.it.api.ccs.adapter.ConnectionType;

Retrieve the cloudconnector properties with the below code snippet:
CloudConnectorContext context = new CloudConnectorContext();
context.setConnectionType(ConnectionType.HTTP);
CloudConnectorProperties props = ITApiFactory.getService(CloudConnectorProperties.class, context);

6. Using the above retrieved properties, you can write the below sample code to establish http connection to the on-premise system.
String virtualAddress = endpoint.getAddress()  <!— Should match the address configured in the cloud connector virtual address -- > 
String locationId = endpoint.getLocationId(); <!- Optional field -->
String proxyHost = props.getProxyHost();
String proxyPort = props.getProxyPort();
Map<String, String> additionalHeaders = props.getAdditionalHeaders();

// create and prepare the client
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(address);
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (locationId != null) {
httpGet.setHeader("SAP-Connectivity-SCC-Location_ID", locationId);
}
setAdditionalHeaders(additionalHeaders, httpGet);

That’s all. Now your custom adapter should be able to connect to on-premise system.

 

References:

https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/c94b8902d3104d51b897a0312e8...

https://help.sap.com/doc/ea5e9983c3d74062aca12b701c263380/Cloud/en-US/AdapterDevGuide_External.pdf

https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/c5c7933b77ba46dbaa9a2c1576d...

 
6 Comments