3

I'm trying to build an OData client on SAP CF that would connect and get content from S4 on-prem system. I have followed this tutorial: https://developers.sap.com/group.s4sdk-js-cloud-foundry.html I have not created and deployed a custom destination and xs-uaa services. Instead I want to use to cFLP product destination and xs-uaa services. Deploying the ts client app works fine but GET query of https://odataclient-quick-antelope.cfapps.sap.hana.ondemand.com/business-partners gives back {} result and in logs I observe errors:

2019-11-24T11:18:18.22+0200 [APP/PROC/WEB/0] OUT {
  "message": "Unable to build destination for service binding: Unable to find a service binding for given name \"uxt_928\"! Found the following bindings: cfservice-xsuaa-broker, cfservice-destination.",
  "level": "warn",
  "custom_fields": {
    "package": "core",
    "messageContext": "destination-accessor"
  },
  "logger": "sap-cloud-sdk-logger",
  "timestamp": "2019-11-24T09:18:18.222Z",
  "msg": "Unable to build destination for service binding: Unable to find a service binding for given name \"uxt_928\"! Found the following bindings: cfservice-xsuaa-broker, cfservice-destination.",
  "written_ts": 1574587098222,
  "written_at": "2019-11-24T09:18:18.222Z"
}

2019-11-24T11:18:18.22+0200 [APP/PROC/WEB/0] OUT {
  "message": "Unable to match a specific XSUAA service instance to the given JWT. The following XSUAA instances are bound: cfservice-cf-service-<removed service ID>. The following one will be selected: cfservice-cf-service-<removed service ID>. This might produce errors in other parts of the system!",
  "level": "warn",
  "custom_fields": {
    "package": "core",
    "messageContext": "environment-accessor"
  },
  "logger": "sap-cloud-sdk-logger",
  "timestamp": "2019-11-24T09:18:18.224Z",
  "msg": "Unable to match a specific XSUAA service instance to the given JWT. The following XSUAA instances are bound: cfservice-cf-service-yosi03-<removed service ID>. The following one will be selected: cfservice-cf-service-<removed service ID>. This might produce errors in other parts of the system!",
  "written_ts": 1574587098224,
  "written_at": "2019-11-24T09:18:18.224Z"
}

The code is basically: controller:

import express from "express";
import { helloWorld } from "./hello-world-route";
import { indexRoute } from "./index-route";
import { businessPartners } from './business-partner-route';

class App {
  public app: express.Application;

  constructor() {
    this.app = express();
    this.config();
    this.routes();
  }

  private config(): void {
    this.app.use(express.json());
    this.app.use(express.urlencoded({ extended: false }));
  }

  private routes(): void {
    const router = express.Router();

    router.get("/", indexRoute);
    router.get("/hello", helloWorld);
    router.get("/business-partners", businessPartners);
    this.app.use("/", router);
  }
}

export default new App().app;

service:

business-partner-route.ts 
import { Request, Response } from 'express';
import { BusinessPartner } from '@sap/cloud-sdk-vdm-business-partner-service';

export async function businessPartners(req: Request, res: Response) {
  getAllBusinessPartners4Deb()
    .then(businessPartners => res.status(200).send(businessPartners))
    .catch(error => res.status(500).send(error));
}

//This version is more cumbersome to breakpoint...
function getAllBusinessPartners(): Promise<BusinessPartner[]> {
  return BusinessPartner.requestBuilder()
    .getAll()
    .execute({
      destinationName: 'uxt_928'
    });
}

//This version is more convenient to breakpoint...
function getAllBusinessPartners4Debug(): Promise<BusinessPartner[]> {
    const reqBuilder = BusinessPartner.requestBuilder();
    const getter = reqBuilder.getAll();
    const resp = getter.execute({ destinationName: 'uxt_928'});
    return resp;
}

xs-security.json

{
  "xsappname": "odataClient",
  "tenant-mode": "shared"
}

manifest.yml, (set for remote debug)

applications:
  - name: odataClient
    path: deployment/
    buildpacks:
      - nodejs_buildpack
    memory: 256M
    command: cd dist/ && node --inspect index.js
    random-route: true
    services:
        - cfservice-destination
        - cfservice-xsuaa-broker

really appreciate any suggestions. Thanks!

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
  • To answer properly, we need to see the destination setup. I would start by removing the underscores from the destination name though. Also, when using cloud connector, the url defined in the destination must start with a `http://` (not `https://`) and specify the port. i.e. http://cloudconnector:443. Using underscores in the hostname or https won't work. – orogers Nov 25 '19 at 17:21
  • I'm facing the same issue and posted all details at https://answers.sap.com/questions/12982450/unable-to-create-sap-connectivity-authentication-h.html. I've checked that I'm using http:// – Gregor Wolf Feb 14 '20 at 17:43

1 Answers1

2

The logs you shared are indeed just warnings, not errors. If no destination binding with the given name was found, the SDK is looking for a destination of this name in the destination service. As there are no other logs regarding the destination service, the destination was probably found. Therefore, this is expected behaviour.

Still, the question remains why there is no data. To answer this, we would need to understand a little bit more about your setup. Are you sure there is data in your system? You said you are connecting to an on premise system. Are you using a cloud connector?

marikaner
  • 304
  • 1
  • 2
  • 15