如何从approuter访问服务目的地?

时间:2019-05-08 12:46:04

标签: s4sdk

看来我已经成功配置了我的approuter:

Approuter

我在SCP驾驶舱中指定了目的地:

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

...返回未找到。

知道我在做什么错吗?

这是我的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

1 个答案:

答案 0 :(得分:3)

您有两个主持人:

  • approuter
  • srv

问题:

症状:

解决方案:

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

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

关注

由于您的 srv 应用程序静态引用了指向绝对路径/odata/v2的链接,因此您将不得不更新 srv 中的每个链接以使用相对路径使用"/odata/v2/"作为您的approuter路由source来镜像目标。对于后一种情况,您会错过"/destination"路径。