Technical Articles
Cloud Integration- Developing Custom Adapters to access On-Premise systems
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:
- 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
- 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:
- 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/c94b8902d3104d51b897a0312e8d05a2.html
https://help.sap.com/doc/ea5e9983c3d74062aca12b701c263380/Cloud/en-US/AdapterDevGuide_External.pdf
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/c5c7933b77ba46dbaa9a2c1576dbb381.html
Dear Appala Naidu,
Great technical write-up!
Thank you for officially supporting this feature and making custom-adapter developers' lives easier!
Best regards,
Fatih
Hi,
thanks for the article!
Is it possible to deploy a custom adapter on an PO 7.5 with on-premise CPI runtime? The *.esa output is not deployable via the Cloud Integration Content Management Cockpit on the PO.
Thanks!
Jürgen
Hi!
First of all, thank you for sharing this article. Very clear!
I'm having a problem, for some reason, these two methods of "endpoint" class are undefined:
String virtualAddress = endpoint.getAddress();
String locationId = endpoint.getLocationId();
Did you build a custom class to include these methods()?
In SAP sample (https://help.sap.com/doc/ea5e9983c3d74062aca12b701c263380/Cloud/en-US/AdapterDevGuide_External.pdf), both "address" and "locationId" are undefined:
Sorry if this question is so basic, but I'm just beginning to develop an adapter, and the official documentation is not really helpful.
Thanks in advance.
Adrian
Hi Adrian, Fatih and Jurgen,
Were you able to use the code snippet in this blog in a working custom adapter and make http connections using Basic Authentication?
Thank you,
Denise
Hi Denise,
I'm afraid I was unable to make it work... and after that, I've changed the way to retrieve the data I needed.
I'm pretty sure building your own custom adapter should be a good thing, but right now I have no time (and not skills enough) in order to invest on this matter.
Regards
Hi
Thanks for your information.
Can custom adapter develop to connection On-Premise application using TCP connection via using Cloud Connector?
SAP official document and thi blog only described HTTP connection.
(https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/c94b8902d3104d51b897a0312e8d05a2.html)
Thanks.