2 weeks ago
Hello all,
I have two capm services serviceA and serviceB in two different capm projects. I need to call serviceB in serviceA and these two services are deployed in SAP BTP.
Is there a way to communicate and send data from serviceA to serviceB?
Any help is appreciated?
Thank you.
Hi @VenkyM ,
You can attempt this solution by generating/exposing the service through an EDMX file as the exchange format, essentially exporting a service API to EDMX.
Use the below command :
cds compile srv -s Servicename -2 edmx > Servicename.edmx
Then, export the "Servicename.edmx" file and import it into your new project to consume its contents within your project.
Use the below code to connect that service/API.
module.exports = cds.service.impl(async function() {
const { testentity } = this.entities;
const service = await cds.connect.to('servicename');
this.on('READ', testentity, request => {
return service.tx(request).run(request.query);
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can find how to consume external services from CAP application in the document below:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @MioYasutake
Thank you for your response.
Will it work from two CAPM services in two different CAM projects?
Should I use destinations or cds.connect(). Please clarify.
@VenkyMIf you want to call serviceB from serviceA, please follow below steps:
"cds": {
"requires": {
"ServiceB": {
"kind": "odata",
"model": "srv/external/ServiceB",
"[production]": {
"credentials": {
"destination": "<destination for serviceB>",
"path": "/path/to/ServiceB"
}
}
}
}
}
User | Count |
---|---|
68 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.