【问题标题】:'Unable to build destination for service binding' with SAP Cloud SDK JS app使用 SAP Cloud SDK JS 应用程序“无法为服务绑定构建目标”
【发布时间】:2020-12-27 03:34:40
【问题描述】:

我正在尝试在 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

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

【问题讨论】:

  • 要正确回答,我们需要查看目标设置。不过,我将从删除目标名称中的下划线开始。此外,在使用云连接器时,目标中定义的 url 必须以 http://(而不是 https://)开头并指定端口。即cloudconnector:443。在主机名或 https 中使用下划线将不起作用。
  • 我面临同样的问题,并在answers.sap.com/questions/12982450/… 发布了所有详细信息。我检查过我使用的是 http://

标签: sap-cloud-platform sap-cloud-sdk hana-xs sap-cloud-foundry


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 2020-08-31
    • 2022-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多