java - 将 JCo 项目部署到 SCP 时出错
问题描述
我正在尝试将 RFC 连接到 Eclipse 中的动态 Web 项目。该项目将部署到 SCP,我在 SCP 上添加了一个目的地,如下所示:
该项目包含一个执行以下代码的 Servlet,这两个组合工作得很好。
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter responseWriter = response.getWriter();
try
{
JCoDestination destination = JCoDestinationManager.getDestination("jcodemo");
JCoRepository repo = destination.getRepository();
JCoFunction rfcConnection = repo.getFunction("ZRFM_GET_EQUIPMENTS");
rfcConnection.execute(destination);
responseWriter.println("<html><head>");
responseWriter.println("</head><body>");
responseWriter.println("<p>Test</p>");
responseWriter.println("</body></html>");
}
}
我想在运行时更改目的地(让用户使用他们自己的帐户),所以我添加了一个DestinationDataProvider
. 它用于制作自定义目的地的多个指南。(我把它留空以节省一些空间,它的功能在这里无关紧要。)
public class DestProvider implements DestinationDataProvider {
@Override
public Properties getDestinationProperties(String arg0) throws DataProviderException {
// TODO Auto-generated method stub
return null;
}
@Override
public void setDestinationDataEventListener(DestinationDataEventListener arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean supportsEvents() {
// TODO Auto-generated method stub
return false;
}
}
为了让 Eclipse 识别导入com.sap.conn.jco.ext.DestinationDataProvider
,我添加了SAPJCo3.jar作为对项目的引用。在这部分之前我不需要导入。
我将这段代码添加到我的 Servlet 以实例化一个。第二次我在 Servlet 中引用它,网页返回500
错误。
DestProvider d = new DestProvider();
我已经尝试了各种各样的事情,但我不断收到错误消息。Java 应用程序的日志也是空的,所以我不知道如何继续。任何帮助将不胜感激。
解决方案
您无法在 SAP Cloud Platform 上注册自己的 DestinationDataProvider。
sapjco3.jar
是独立的 SAP Java 连接器,不适合在 SCP 上使用/部署。这个平台已经附带了所有必要的工件,包括一个特殊的 JCo 客户端版本。与本地 SAP 系统的 RFC 连接是通过到 SAP Cloud 连接器的 TLS 隧道实现的。
也许本教程有助于理解架构以及如何在 SAP Cloud Platform 上使用 JCo RFC:
https ://www.sap.com/germany/developer/tutorials/hcp-scc-onpremise-extension-jco-rfc.html
对于自定义 JCo 目标,您应该能够使用JCoCustomDestination类,该类将允许切换用户登录凭据,但不能更改定义目标 SAP 系统的登录参数。
推荐阅读
- android - 在我的 ViewModel 中观察(并处理)LiveData。然后才通过 if 来查看,通过拆分为更小的 LaveData 对象
- linux - Cassandra:Linux 和 Windows 兼容吗?
- ios - 为什么 CATransaction.setCompletionBlock 似乎没有被调用
- c# - UWP如何允许在RelativePanel的边界之外绘制子元素
- azure - Azure 流分析 - 如何通过加入参考 blob 数据使用 ST_WITHIN 方法包含来自输入数据的 lat 和 long 多边形详细信息
- php - 从 jquery 发送 getJSON 请求时出现内部服务器错误
- javascript - 在新选项卡中打开 PDF 文件时量角器测试失败
- angularjs - angularJS 中的服务不起作用。ASP.NET 核心
- c - 将 char 打印为整数
- python - 如何使用 facebook SDK 从活动 ID 中获取活动名称?