我正在尝试在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
非常感谢任何建议。 谢谢!
答案 0 :(得分:2)
您共享的日志确实只是警告,而不是错误。如果未找到具有给定名称的目标绑定,则SDK会在目标服务中寻找该名称的目标。由于没有关于目标服务的其他日志,因此可能找到了目标。因此,这是预期的行为。
仍然,问题仍然是为什么没有数据。 要回答这个问题,我们需要更多地了解您的设置。您确定系统中有数据吗? 您说要连接到本地系统。您在使用云连接器吗?