Skip to content

Instantly share code, notes, and snippets.

@ilgrosso
Last active August 29, 2015 13:58
Show Gist options
  • Save ilgrosso/10097094 to your computer and use it in GitHub Desktop.
Save ilgrosso/10097094 to your computer and use it in GitHub Desktop.
Invoking V3 FunctionImport via Olingo4 client library
Edm edm = getClient().getRetrieveRequestFactory().
getMetadataRequest(testStaticServiceRootURL).execute().getBody();
EdmFunction func = edm.getUnboundFunction("GetPrimitiveString", null);
EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment(URIUtils.operationImportURISegment(container, func.getName()));
ODataProperty property = getClient().getInvokeRequestFactory().
getInvokeRequest(builder.build(), func).execute().getBody();
@ilgrosso
Copy link
Author

ilgrosso commented Apr 8, 2014

Lines 1:2 - get metadata - this step can be cached for multiple invocations

Line 4 - via metadata, get to the function to be invoked through function import

Line 6:7 - get entity container for the given metadata and use URIBuilder as facility for building the invoke URI for the function import - these two steps are optional if one wants to provide directly the full URL in the subsequent statement, in place of builder.build()

Lines 10:11 - an invoke request is obtained, and result is taken as ODataProperty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment