1

Following the problem from question: Generate VDM for SFSF using Java in SAP Cloud SDK: Generated URI is wrong

I generated a Virtual Data Model from a metadata file from SFSF using the Maven plugin and SAP Cloud SDK for Java.

The generator works correctly, however the URI generated is not what SFSF is expecting:

  • Generated URI: /odata/v2/SFODataSet

  • Expected URI: /odata/v2 or /odata/v2/JobRequisition

(SFODataSet entity does not exist, and SFSF gives an error when trying to access it).

Anyway, I proceed and change the DEFAULT_SERVICE_PATH in the generated files to /odata/v2 and create the following servlet that includes the query:

@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());
        }
    }
}

This queries a single job requisition (with the id 2126). There's no need to add the option .withServicePath() because it's already changed.

However, when running the app, I get an Internal Server Error after 10-20 second of waiting.

In the logs I can see the following:

  • The destination is fetched correctly
  • The HTTP request is correct
  • SFSF responds with the correct data

But just after the data is received there's an error:

"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." }

Find in Drive here:

  • Debug logs (SDKapplogs.txt)
  • JSON response from SFSF (response.json)

Any help would be appreciated.

kepair
  • 67
  • 6
  • 1
    Thank you for opening a new question for this. In order to tackle this we need a bit more information: First please provide the logs in a human readable format, the txt file is not correctly encoded and the excel is also a pain to read. Also please provide the full stack trace in the question. Also please confirm that the payload you receive actually matches what is expected. – MatKuhr Feb 27 '20 at 10:38
  • Does the problem still persist for you? – MatKuhr Mar 03 '20 at 12:42
  • Hi, Yes, I still have the same problem. I updated the question to give more details. I'm trying to get the stack trace as well. – kepair Mar 03 '20 at 16:03
  • The application is throwing an `EdmSimpleTypeException` when trying to deserialize the JSON payload to entity object. This operation is happening within the _SAP Service SDK_, a dependency that the _SAP Cloud SDK_ uses to handle OData V2 requests. Most likely this is failing due to an unexpected object within the JSON code. In order to reproduce the situation, can you please attach an OData V2 response JSON sample? E.g. the contents from `/odata/v2/JobRequisition(2126)?$format=json` (i suppose) – Alexander Dümont Mar 04 '20 at 15:58
  • Hi @AlexanderDümont, I just uploaded it to Drive. – kepair Mar 05 '20 at 09:20

1 Answers1

1

The EDMX file that you've used to generate the VDM from is not compatible with the remote OData service responses. Please ask the maintainer of the OData service to provide an up-to-date metadata file. You can also try and download it directly from http://[URL]/odata/v2/$metadata.

I found about half of the JSON sample payload that you attached was not compatible with the EDMX file published on API Business Hub.

  • The response contains unknown entity properties which cannot be matched with the metadata:

    "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"}}
    
  • The response contains unexpected null values for entity properties which are not allowed to be null:

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

Unfortunately the errors are not handled gracefully and will shutdown any deserialization attempt. Since this is happening within the third party Olingo library of SAP Service SDK, we cannot fix or change it, or provide a meaningful workaround.

You will need to make sure the correct metadata file is used, from start to end.

Alexander Dümont
  • 903
  • 1
  • 5
  • 9
  • Thanks for your analysis. I tried several times using the metadata from the same system without luck. I guess SFSF metadata, the generator and Cloud SDK are not best friends at the moment. I'll park this project until there's an updated example or tutorial using a real SFSF system. Thanks for your answer anyway, definitely helped! – kepair Mar 19 '20 at 09:44