Skip to Content
0
Dec 28, 2020 at 05:14 AM

CAP: Invoking an external ODATA Service via Java

136 Views

Hello All,

I am trying to invoke an external ODATA Service using the CAP Java framework. I am following this example of invoking the OData NorthWind service (although it is NodeJS). https://blogs.sap.com/2020/05/26/cap-consume-external-service-part-1/

I have done the following:

1. Import the EDMX file

2. Generate the CSN file and update the package.json

3. Create a service definition in form of a CDS file.

As recommended by this example. I am attempting to create a handler, wherein a call needs to be made out to the external ODATA service. However I am not able to proceed with the exact CDS command to connect to an ODATA service. Looking at guidance on how to write code like this NodeJS snippet

	const { Products } = this.entities;
	const service = await cds.connect.to('NorthWind');
	this.on('READ', Products, request => {
		return service.tx(request).run(request.query);
	});

Any suggestions or pointers on this will be highly appreciated.

Regards,

Prabal Rakshit