3

我正在尝试在 SAP CF 上构建一个 OData 客户端,该客户端将连接并从 S4 本地系统获取内容。我已遵循本教程:https ://developers.sap.com/group.s4sdk-js-cloud-foundry.html 我尚未创建和部署自定义目标和 xs-uaa 服务。相反,我想使用 cFLP 产品目的地和 xs-uaa 服务。部署 ts 客户端应用程序工作正常,但https://odataclient-quick-antelope.cfapps.sap.hana.ondemand.com/business-partners的 GET 查询返回 {} 结果,在日志中我观察到错误:

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"
}

代码基本上是:控制器:

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;

服务:

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,(设置为远程调试)

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

非常感谢任何建议。谢谢!

4

1 回答 1

2

您共享的日志确实只是警告,而不是错误。如果未找到具有给定名称的目标绑定,则 SDK 正在目标服务中寻找该名称的目标。由于没有关于目标服务的其他日志,因此可能找到了目标。因此,这是预期的行为。

尽管如此,问题仍然是为什么没有数据。要回答这个问题,我们需要更多地了解您的设置。您确定系统中有数据吗?您说您正在连接到本地系统。您使用的是云连接器吗?

于 2019-11-25T15:02:04.880 回答