Swastik
Swastik

Reputation: 531

How to ping sap s4 service endpoint from cloud sdk?

we are building ping api for one s4 odata service. From scp application we want to call service endpoint at a repeated interval. How to call s4 service endpoint from cloud-sdk.Generated VDM only gives us the operations endpoints.

Revert for more info.

Thanks Swastik

Upvotes: 1

Views: 398

Answers (2)

MatKuhr
MatKuhr

Reputation: 563

You can leverage the HttpClientAccessor to obtain a client for your target system and then perform a simple head request towards the service:

final HttpClient httpClient = HttpClientAccessor.getHttpClient(
                 DestinationAccessor.getDestination("MyDestination").asHttp());

final HttpResponse response = httpClient.execute(
                 new HttpHead(BusinessPartnerService.DEFAULT_SERVICE_PATH));

assertThat(response.getStatusLine().getStatusCode()).isEqualTo(HttpStatus.SC_OK);

Here I took the BusinessPartnerService of S/4HANA Cloud as an example.

Upvotes: 1

Artyom Kovalyov
Artyom Kovalyov

Reputation: 409

Is it like a check server availability ping or what do you mean by ping API?

You can use any operation like getAll() or getByKey() to implement a "ping". It very much depends on your knowledge of the service to identify which exact operation to use to make sure the service behaves as you'd expect.

Do you have a certain OData protocol feature in mind that would help to solve your problem, by the way?

You can find more details on the OData client capabilities here. Also, take a look at connectivity options.

If you explain more behind what you call ping we might suggest a bit more ideas. It overall seems like the task is beyond what the SDK should do, but more of an implementation detail of certain service infrastructure.

Upvotes: 0

Related Questions