Connectivity Features
The SAP Cloud SDK offers a variety of connectivity features that help to connect to systems and services.
At its core, the SAP Cloud SDK uses Destination
objects as an abstraction of (remote) services.
Ultimately, a Destination
will be converted into an HTTP Client that can be used to actually send requests to the target.
Hereby, the SAP Cloud SDK supports both cloud and on-premise targets.
Furthermore, the SAP Cloud SDK also offers various means of running and testing applications that use these connectivity features in non-productive environments, such as in an CI/CD pipeline. That way, you are well equipped to develop robust and reliable applications.
Accessing Destinations
A destination is an abstraction of a real system or service that applications may want to connect to. It is a representation of the connection details, such as the URL, authentication, proxy settings, and HTTP headers. The destination concept is an integral part of the SAP Cloud SDK for Java.
The SAP Cloud SDK offers APIs to load destinations from following sources:
- From the BTP Destination Service on Cloud Foundry.
- Via the
DestinationAccessor
API
- Via the
- From Service Bindings.
- From existing
Destination
objects.- Via the
DefaultHttpDestination
API
- Via the
Using Destinations
Once a Destination
has been retrieved, it can be used to connect to the system or service it represents.
This is done by converting the given Destination
into an HTTP client, which is then used to send requests to the system or service.
For OData and OpenApi Services
While the Destination
to HTTP client conversion can be done explicitly to connect to any system or service, the SAP Cloud SDK provides convenient integrations in generated OData and OpenApi clients.
- OData V4 Example
- OData V2 Example
- OpenApi Example
Destination myDestination;
SomeODataV4Service myService;
var serviceResponse = myService.getAllEntities().execute(myDestination);
Destination myDestination;
SomeODataV2Service myService;
var serviceResponse = myService.getAllEntities().executeRequest(myDestination);
Destination myDestination;
var myService = new SomeOpenApiService(myDestination);
var serviceResponse = myService.entitiesGet();
When running code as above, the SAP Cloud SDK internally takes care of converting the provided Destination
into a suitable HTTP client.
This process is fully transparent to the user and has proven to be sufficient for almost all use cases.
For Other Services
If the above approach is not applicable, the Destination
to HTTP client conversion can be done explicitly as described here.
To Read Its Configuration
A Destination
consists of a set of properties that describe the connection details of the represented system or service.
These properties can be read from the Destination
object as follows:
Destination myDestination;
String destinationName = myDestination.get(DestinationProperty.NAME).getOrElse("");
Reading those properties is most useful when a Destination
is retrieved from the BTP Destination Service, as it allows to read the properties that have been provided by a user via the BTP Cockpit.
Please refer to this documentation for more details.