SFSF OData 调用:无法将响应转换为 ODataFeed:发生 'EdmSimpleTypeException'

SFSF OData call: Failed to convert response into ODataFeed: An 'EdmSimpleTypeException' occurred

按照提问的问题:

我使用 Maven 插件和 SAP Cloud SDK 从 SFSF metadata file 为 Java 生成了一个虚拟数据模型。

生成器工作正常,但生成的 URI 不是 SFSF 所期望的:

(SFODataSet实体不存在,SFSF访问时报错)

无论如何,我继续并将生成的文件中的 DEFAULT_SERVICE_PATH 更改为 /odata/v2 并创建以下包含查询的 servlet:

@WebServlet("/req")
public class JobReqServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;
    private static final Logger logger = LoggerFactory.getLogger(JobReqServlet.class);

    private final ErpHttpDestination destination = DestinationAccessor.getDestination("sfsf-sdk-dest").asHttp()
            .decorate(DefaultErpHttpDestination::new);


    @Override
    protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {
        try {
            long id = 2126;
            final JobRequisition jobReqs = new DefaultRCMJobRequisitionService()
                .getJobRequisitionByKey(id)
                .execute(destination);
            response.getWriter().write("Done!");
        } catch (final ODataException e) {
            logger.error(e.getMessage(), e);
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            response.getWriter().write(e.getMessage());
        }
    }
}

这将查询单个工作申请(ID 为 2126)。不需要添加选项 .withServicePath() 因为它已经改变了。

但是,当 运行 应用程序时,我在等待 10-20 秒后收到 内部服务器错误

在日志中我可以看到以下内容:

但是刚收到数据就报错:

"com.sap.cloud.sdk.odatav2.connectivity.ODataQuery","thread":"http-nio-0.0.0.0-8080-exec-3","level":"ERROR","categories":[],"msg":"Failed to convert response into ODataFeed: An exception of type 'EdmSimpleTypeException' occurred." }

在云端硬盘中查找 here:

如有任何帮助,我们将不胜感激。

您用来生成 VDM 的 EDMX 文件与远程 OData 服务响应不兼容。请要求 OData 服务的维护者提供最新的元数据文件。您也可以尝试直接从 http://[URL]/odata/v2/$metadata.

下载

我发现您附加的 JSON 示例负载中大约有一半与 API Business Hub 上发布的 EDMX 文件不兼容。

  • 响应包含无法与元数据匹配的未知实体属性:

    "departmentCode": null
    "locationCode": null
    "divisionCode": null
    "costCenterCode": null
    "instrGen": null
    "legalEntityCode": null
    "templateName": "Standard Job Requisition"
    "routeMap": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/routeMap"}}
    "motorVeh": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/motorVeh"}}
    "payType": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/payType"}}
    "requiredTravel": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/requiredTravel"}}
    "state": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/state"}}
    "jobProfile": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/jobProfile"}}
    "division_obj": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/division_obj"}}
    "legalEntity_obj": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/legalEntity_obj"}}
    "jobReqFwdCandidates": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/jobReqFwdCandidates"}}
    "status": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/status"}}
    "budgeted": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/budgeted"}}
    "jobApplications": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/jobApplications"}}
    "shiftSchedule": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/shiftSchedule"}}
    "interviewGuide": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/interviewGuide"}}
    "jobAnalyzerReportingData": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/jobAnalyzerReportingData"}}
    "assessment": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/assessment"}}
    "adCode": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/adCode"}}
    "flsa": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/flsa"}}
    "costCenter_obj": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/costCenter_obj"}}
    "filter1": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/filter1"}}
    "filter2": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/filter2"}}
    "filter3": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/filter3"}}
    "eeoJobCat": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/eeoJobCat"}}
    "location_objlist": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/location_objlist"}}
    "accommo": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/accommo"}}
    "experienceReq": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/experienceReq"}}
    "relocationPack": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/relocationPack"}}
    "rsnVacancy": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/rsnVacancy"}}
    "location_obj": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/location_obj"}}
    "competencies": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/competencies"}}
    "department_obj": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/department_obj"}}
    "PD": {"__deferred": {"uri": "https://[URL]/odata/v2/JobRequisition(2126L)/PD"}}
    
  • 响应包含不允许为空的实体属性的意外空值:

    "closedDateTime": null
    "timeToFill": null
    "jobReqGUId": null
    "overallScaleName": null
    "lastModifiedProxyUserId": null
    "positionNumber": null
    "age": null
    

不幸的是,错误没有得到妥善处理,并且将关闭任何反序列化尝试。由于这发生在 Olingo SAP 服务 SDK 的第三方库中,我们无法修复或更改它,也无法提供有意义的解决方法。

您需要确保从头到尾都使用了正确的元数据文件。