diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java index a29d1248d..d8d2538e6 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java @@ -25,7 +25,7 @@ import org.apache.olingo.commons.api.domain.ODataValue; public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory { /** - * Gets an invoke request instance for the first function import with the given name (no overloading supported). + * Gets an invoke request instance for the function import with the given name and no parameters. * * @param OData domain object result, derived from return type defined in the function import * @param functionImportName operation to be invoked @@ -35,7 +35,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory { String functionImportName); /** - * Gets an invoke request instance for the first function import with the given name (no overloading supported). + * Gets an invoke request instance for the function import with the given name and matching parameter names. * * @param OData domain object result, derived from return type defined in the function import * @param functionImportName operation to be invoked diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java index c6a6fd3a3..de22c30e3 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.client.core.communication.request.invoke.v3; +import java.util.ArrayList; import java.util.Map; import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; @@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.commons.api.edm.EdmActionImport; import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmSchema; @@ -63,9 +65,16 @@ public class EdmEnabledInvokeRequestFactoryImpl throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); } + final EdmFunction function = edmClient.getCachedEdm(). + getUnboundFunction(efi.getFunctionFqn(), + parameters == null ? null : new ArrayList(parameters.keySet())); + if (function == null) { + throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); + } + return getInvokeRequest( edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(), - efi.getUnboundFunctions().get(0), + function, parameters); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java index b33e22592..4df6c3ff4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.client.core.communication.request.invoke.v4; +import java.util.ArrayList; import java.util.Map; import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; @@ -26,6 +27,7 @@ import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.commons.api.edm.EdmActionImport; import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmSchema; @@ -63,9 +65,16 @@ public class EdmEnabledInvokeRequestFactoryImpl throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); } + final EdmFunction function = edmClient.getCachedEdm(). + getUnboundFunction(efi.getFunctionFqn(), + parameters == null ? null : new ArrayList(parameters.keySet())); + if (function == null) { + throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); + } + return getInvokeRequest( edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(), - efi.getUnboundFunctions().get(0), + function, parameters); }