首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sap-cf-mailer VError:没有与目的地匹配的服务

sap-cf-mailer VError:没有与目的地匹配的服务
EN

Stack Overflow用户
提问于 2021-11-03 10:42:56
回答 1查看 739关注 0票数 0

我有一个SAP应用程序,我试图使用sap-cf包从CAP应用程序发送电子邮件。

正如示例中提到的,我在BTP中创建了一个目标服务,当我试图将应用程序部署到BTP时,它失败了。

当我使用cds watch在本地运行应用程序时,它会给出以下错误

VError:没有与目的地匹配的服务

这是我的mta.yaml

代码语言:javascript
复制
## Generated mta.yaml based on template version 0.4.0
## appName = CapTest
## language=nodejs; multitenant=false
## approuter=
_schema-version: '3.1'
ID: CapTest
version: 1.0.0
description: "A simple CAP project."
parameters:
  enable-parallel-deployments: true
   
build-parameters:
  before-all:
   - builder: custom
     commands:
      - npm install --production
      - npx -p @sap/cds-dk cds build --production

modules:
 # --------------------- SERVER MODULE ------------------------
 - name: CapTest-srv
 # ------------------------------------------------------------
   type: nodejs
   path: gen/srv
   parameters:
     buildpack: nodejs_buildpack
   requires:
    # Resources extracted from CAP configuration
    - name: CapTest-db
    - name: captest-destination-srv
   provides:
    - name: srv-api      # required by consumers of CAP services (e.g. approuter)
      properties:
        srv-url: ${default-url}
    
     
 # -------------------- SIDECAR MODULE ------------------------
 - name: CapTest-db-deployer
 # ------------------------------------------------------------
   type: hdb
   path: gen/db  
   parameters:
     buildpack: nodejs_buildpack
   requires:
    # 'hana' and 'xsuaa' resources extracted from CAP configuration
    - name: CapTest-db


resources:
 # services extracted from CAP configuration
 # 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
# ------------------------------------------------------------
 - name: CapTest-db
# ------------------------------------------------------------
   type: com.sap.xs.hdi-container
   parameters:
     service: hana  # or 'hanatrial' on trial landscapes
     service-plan: hdi-shared
   properties:
     hdi-service-name: ${service-name}

 - name: captest-destination-srv
   type: org.cloudfoundry.existing-service

这是CDS服务的js文件。

代码语言:javascript
复制
const cds = require('@sap/cds')

const SapCfMailer = require('sap-cf-mailer').default;
const transporter = new SapCfMailer("MAILTRAP");

module.exports = cds.service.impl(function () {

    this.on('sendmail', sendmail);
});


async function sendmail(req) {
    try {
        const result = await transporter.sendMail({
            to: 'someoneimportant@sap.com',
            subject: `This is the mail subject`,
            text: `body of the email`
        });
        return JSON.stringify(result);
    }
    catch{

    }
};

我在下面的样本中找到这个

从nodejs应用程序发送电子邮件

将电子邮件集成到CAP应用程序中

EN

回答 1

Stack Overflow用户

发布于 2022-01-12 13:59:55

您是否创建了默认的..。json文件?它们需要连接到BTP租户上的远程服务。你可以在SAP博客上找到更多有关这方面的信息,比如:https://blogs.sap.com/2020/04/03/sap-application-router/

还可以使用sap-cf-localenv命令:https://github.com/jowavp/sap-cf-localenv

据我所知,这个工具是实验性的,只适用于CLI V6。更高版本正在以另一种格式获取服务键,这将导致命令失败。

你好,托马斯

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69823453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档