如何从审批者访问服务目的地?

How to access service destination from approuter?

看来我的approuter配置成功了:

Approuter

我在 SCP Cockpit 中为我的服务指定了目的地:

destination config in SCP Cockpit

并且我在 xs-app.json:

中维护了目的地
    {
  "welcomeFile": "/webapp/index.html",
  "authenticationMethod": "route",
  "logout": {
    "logoutEndpoint": "/do/logout"
  },
  "routes": [
    {
      "source": "/destination",
      "target": "/",
      "destination": "service-destination"
    }
  ]
}

我现在的问题是如何通过 approuter 访问我的服务目的地?

不应该是这样的吗: https://qfrrz1oj5pilzrw8zations-approuter.cfapps.eu10.hana.ondemand.com/webapp/index.html/destination

Accessing service via Approuter

...它 returns 未找到。

知道我做错了什么吗?

这是我的mta.yaml(如果相关):

    ID: oDataAuthorizations
_schema-version: '2.1'
version: 0.0.1
modules:
  - name: oDataAuthorizations-db
    type: hdb
    path: db
    parameters:
      memory: 256M
      disk-quota: 256M
    requires:
      - name: oDataAuthorizations-hdi-container
  - name: oDataAuthorizations-srv
    type: java
    path: srv
    parameters:
      memory: 1024M
    provides:
      - name: srv_api
        properties:
          url: '${default-url}'
    requires:
      - name: oDataAuthorizations-hdi-container
        properties:
          JBP_CONFIG_RESOURCE_CONFIGURATION: '[tomcat/webapps/ROOT/META-INF/context.xml: {"service_name_for_DefaultDB" : "~{hdi-container-name}"}]'
      - name: xsuaa-auto
  - name: approuter
    type: html5
    path: approuter
    parameters:
      disk-quota: 256M
      memory: 256M
    build-parameters:
      builder: grunt
    requires:
      - name: dest_oDataAuthorizations
      - name: srv_api
        group: destinations
        properties:
          name: service-destination
          url: '~{url}'
          forwardAuthToken: true
      - name: xsuaa-auto



resources:
  - name: oDataAuthorizations-hdi-container
    type: com.sap.xs.hdi-container
    properties:
      hdi-container-name: '${service-name}'
  - name: xsuaa-auto
    type: org.cloudfoundry.managed-service
    parameters:
      path: ./cds-security.json
      service-plan: application
      service: xsuaa
      config:
        xsappname: xsuaa-auto
        tenant-mode: dedicated
  - name: dest_oDataAuthorizations
    parameters:
      service-plan: lite
      service: destination
    type: org.cloudfoundry.managed-service

您有两个主机:

  • 批准者
  • srv

问题:

  • https://approuter/destination/ will proxy to https://srv/

    注意 URL 中的根路径。您会看到目的地的路径段被审批者忽略了。相反,它会查找 xs-app.json 文件的 routes[0].target 声明。

症状:

解决方法:

调整您的 xs-app.json 以正确引用目标端点路径:

  "routes": [
    {
      "source": "/destination",
      "target": "/odata/v2",
      "destination": "service-destination"
    }

跟进

由于您的 srv 应用程序静态引用 links 到绝对路径 /odata/v2,您要么必须更新 link srv使用相对路径,使用"/odata/v2/"作为你的approuter路由source镜像目标。对于后一种情况,您会错过 "/destination" 路径。