You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/integration/calesi.md
+52-3Lines changed: 52 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Integrating remote services - from other applications, third-party services, or
10
10
>
11
11
> 1. Remote services are proxied by CAP services, ... → *everything's a CAP service*
12
12
> 2. consumed in protocol-agnostic ways → *... as if they were local*
13
-
> 3. mocked out of the box → *inner-loop development*
13
+
> 3. mocked out of the box → *fast-track inner-loop development*
14
14
> 4. with varying implementations → *evolution w/o disruption*
15
15
> 5. extensible through event handlers → *intrinsic extensibility*
16
16
>
@@ -801,12 +801,16 @@ With mashed up models, you can run applications in _'airplane mode'_ without ups
801
801
802
802

803
803
804
+
> [!tip] Fast-track Inner-Loop Development → Spawning Parallel Tracks
805
+
>
806
+
> The mocked-out-of-the-box capabilities of CAP, with remoted services mocked in-process and a shared in-memory database, allows us to greatly speed up development and time to market. For real remote operations there is additional investment required, of course. But the agnostic nature of CAP-level Service Integration also allows you to spawn two working tracks running in parallel: One team to focus on domain and functionality, and another one to work on the integration logic under the hood.
807
+
804
808
We'll learn more about mocking and inner loop development in the [next chapter](#inner-loop-development).
805
809
806
810
807
811
#### Integration Logic Required
808
812
809
-
While everything just works nicely when mocked in-process and with a shared in-memory database, let's get a bit more realistic and use `cds mock` to run the services in separate processes.
813
+
While everything just works nicely when mocked in-process and with a shared in-memory database, let's move closer to the target setup and use `cds mock` to run the services to be integratedin separate processes.
810
814
811
815
1. First run these commands **in two separate terminals**:
812
816
@@ -881,12 +885,57 @@ The log shows bulk requests – the Fiori client desperately trying to fetch the
881
885
We see there are specific implementions required, to actually integrate remote services at runtime. We deep dive into one possible solution for that next.
882
886
883
887
888
+
889
+
884
890
## Integration Logic
885
891
886
-
To actually integrate remote services at runtime, custom code is required. In the xtravels sample we implemented that in`srv/travel-service.js`, which is automatically picked up by the CAP runtime as service implementation forthe `TravelService` definedin`srv/travel-service.cds`.
892
+
This chapter walks you through the typical use cases and solution patterns that you should be aware of when implementing required integration logic. The following sections do that on the example of [CAP Node.js SDK](../../node.js/); the same principles and patterns apply to CAP Java, as documented in the [CAP Java SDK](../../java/) reference documentation.
893
+
894
+
887
895
888
896
### Connecting to Remote Services
889
897
898
+
It all starts with connecting to remote services, which we do like that in the xtravels project:
The `cds.connect` functions used here is the common way to address service instances, that is commonly used for and works the same way for both, local as well as remote services:
910
+
911
+
- for**local** services, it returns the local service providers – i.e., instances of [`cds.ApplicationService`](../../node.js/app-services), or your application-specific subclases thereof.
912
+
- for**remote** services, it returns a remote service proxy – i.e., instances of [`cds.RemoteService`](../../node.js/remote-services), generically constructed by the client libs.
913
+
- **both** inherit from the [`cds.Service`](../../node.js/core-services) base class, which constitutes the uniform programming interface for consuming CAP services – agnostic to underlying protocols, and agnostic to whether its local or remote at all.
914
+
915
+

917
+
918
+
### Uniform, Agnostic APIs
919
+
920
+
The uniform, agnostic programming interface offered through [`cds.Service`](../../node.js/core-services) is centered around these methods:
921
+
922
+
- [`srv.send (<request>)`](../../node.js/core-services#srv-send-request) → synchronous communication, for all kinds of services.
923
+
- [`srv.emit (<event>)`](../../node.js/core-services#srv-emit-event) → asynchronous communication, via messaging middlewares.
924
+
- [`srv.run (<query>)`](../../node.js/core-services#srv-run-query) → execute CRUD queries with services that support that, like CAP services, OData services, or GraphQL services.
0 commit comments