cancel
Showing results for 
Search instead for 
Did you mean: 

CAP Java: Adding Remote Service to Application.yaml causes service to disappear

03-30-2021 2:29 AM
1261 views 2 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello experts!

I have a quick question. When I identify an oData service in application.yaml as a remote service, the service disappears from the page that the CAP framework automatically generates. I was wondering whether this behavior is expected and if it is, what it's purpose is. If it's unexpected, then I suppose something is wrong somewhere else in my code. If that's the case, does anyone know how to resolve this?

Steps to reproduce:

  1. Generate new application.
  2. Add dependencies for remote services as described in the CAP documentation.
  3. Import edmx definition of the odata service.
  4. Define the service in cds (using { <service name> } from '<file name>'
    At this point, the service is visible.
  5. Add the remote service definition to the application.yaml.
    At this point, the service disappears.
0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

marcbecker
Product and Topic Expert
Product and Topic Expert

Hi,

these sections in the documentation kind of explain the behaviour: https://cap.cloud.sap/docs/java/consumption-api#cdsservices

In general you need to distinguish between Application Services and Remote Services. Those two serve two different purposes:

Application Services define the APIs that are exposed by a CAP application to its clients. [...] Typically these services are served by protocol adapters, such as OData V4 [...] By default an Application Service is created for every service that is defined in the CDS model.
Remote Services are CQN-based clients for remote APIs, for example OData. [...] If a Remote Service is created for a service definition in the CDS model, no Application Service is automatically created for that definition.

The index page you are referring to only lists Application Services, as these are served by protocol adapters and these are the APIs that your application provides to its clients. Remote Services are just CQN-based clients (think Apache HTTP Client). A Remote Service is not automatically served by your application again to its clients.

Due to the default behaviour described in the docs, that if not otherwise specified an Application Service is created for each service in the CDS model, the behaviour changes as soon as you define a Remote Service.

If you want to proxy a Remote Service, meaning provide its API again in your application, you can create both a Remote Service and an Application Service based on the same CDS model definition. Please have a look at our properties overview page, specifically at the section "cds.application.services", which shows how you can explicitly create Application Services through configuration, similar to how you create Remote Services through configuration. You could then forward all incoming queries on the Application Service to the Remote Service and replace the Application Service's default behaviour of forwarding queries to the Persistence Service (database).

Hope this clarifies things a bit.

Marc, thank you again! You are my hero.

Answers (0)