问题
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." }
Here are the logs (updated to Drive here), I'm trying to get also the stack trace, I'll update the question as I get it.
Any help would be appreciated.
来源:https://stackoverflow.com/questions/60423361/sfsf-odata-call-failed-to-convert-response-into-odatafeed-an-edmsimpletypeexc