
安装并配置好SAP云连接器(SAP Cloud Connector),您可以参考这里 install SAP Cloud Connector with Docker, 或者在这里下载可安装版本。
在本项目中,我们使用 ES5 作为我们后端基于ABAP的OData数据源. Configure OP system in SAP Cloud Connector, 在SAP Cloud Connector里您需要配置自己的Location ID(任何利于区分的字符串即可).
在MTA.yaml中配置Destination属性.
定义Destination名称为 es5, 可以从您配置的SAP Cloud Connector中获取到URL。并输入相应的ES5系统的用户名和密码(注意这里并不是SAP i-用户的域密码)。另外,需要添加一个参数sap-client,其值为002,注意这里的002必须用双引号括起来,否则会被转义成数字。这里的URL是SAP云连接器里配置好的Cloud To OnPremise配置里获取到。
浏览到destination_approuter模块,将YOUR.CUSTOM.DOMAIN.COM更新为您自己的真实域名。
ID: destination-approuter
_schema-version: "2.1"
version: 1.0.0
modules:
- name: destination_approuter
type: approuter.nodejs
path: approuter
parameters:
disk-quota: 256M
memory: 256M
routes:
- route: opes5.YOUR.CUSTOM.DOMAIN.COM
requires:
- name: es5-xsuaa
- name: es5-destination
- name: es5-connectivity
resources:
- name: es5-connectivity
type: org.cloudfoundry.managed-service
parameters:
service: connectivity
service-plan: lite
- name: es5-destination
type: org.cloudfoundry.managed-service
parameters:
config:
HTML5Runtime_enabled: true
init_data:
instance:
destinations:
- Authentication: BasicAuthentication
Name: es5
ProxyType: OnPremise
Type: HTTP
URL: http://<Your.OnPremise.OData.Service>;
User: i000000
Password: xxxxxxxxxx
sap-client: "002"
existing_destinations_policy: update
version: 1.0.0
service: destination
service-name: es5-destination
service-plan: lite
- name: es5-xsuaa
parameters:
path: ./xs-security.json
service-plan: application
service: xsuaa
type: org.cloudfoundry.managed-service
配置自定义域名
在BTP@AliCloud上,根据法规要求合法的域名是必须项目。您可以通过命令行 cf domains
来确认自己是否已经具有合法的域名。如果拥有合法域名将会显示成如下图示:
另外,打开文件xs-security.json,按以下格式添加自己的域名到oauth2-configuration下:
{
"xsappname": "desttest",
"tenant-mode": "dedicated",
"description": "Security profile of called application",
"scopes": [
{
"name": "uaa.user",
"description": "UAA"
}
],
"role-templates": [
{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": [
"uaa.user"
]
}
],
"oauth2-configuration": {
"redirect-uris": [
"https://*.YOUR.CUSTOM.DOMAIN.COM/**"
]
}
}
检查文件xs-app.json中关于路由的配置。Destination es5应该在列,如果没有,需要按以下格式添加进去。所有URL中包含es5的请求都会路由到Destination es5。Connectivity服务作为代理功能与SAP云连接器配合打通一个从内网到云环境的通道,从而实现从云端访问内网数据源的功能。
{
"welcomeFile": "index.html",
"authenticationMethod": "route",
"routes": [
{
"source": "^/user-api(.*)",
"target": "$1",
"service": "sap-approuter-userapi"
},
{
"source": "^/es5(.*)",
"target": "$1",
"destination": "es5"
},
{
"source": "^(.*)$",
"target": "$1",
"authenticationType": "xsuaa",
"localDir": "./"
}
]
}
mbt build -t ./
cf deploy destination-approuter_1.0.0.mtar
部署完成后,并完成相应的配置,即可测试您的应用。登陆到您的BTP子账号,进入CF org/space/Applications, 找到部署好的应用destination_approuter,即可测试。
登陆到SAP BTP子账号,浏览到Cloud Foundry Org/Space。打开应用destination_approuter。访问URL链接打开我们的web应用。这个应用会显示我们当前登陆的用户名字。
将后缀index.html更新为/es5/Products?format=json, OnPremise系统的数据将会正常被获取并显示。
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
23 | |
22 | |
15 | |
13 | |
10 | |
9 | |
7 | |
7 | |
6 |