Beispiel #1
0
        //------------------------------------------
        // WCF METHODS WHICH RETURN A VALUE
        //------------------------------------------

        public static Task <RETURN_TYPE> CallWebMethodAsync <RETURN_TYPE, INTERFACE_TYPE>(
            string endpointAddress,
            string webMethodName,
            IDictionary <string, object> requestParameters,
            string soapVersion) where INTERFACE_TYPE : class
        {
            // Call the web method
            var webMethodsCaller = new CSHTML5_ClientBase <INTERFACE_TYPE> .WebMethodsCaller(endpointAddress);

            Task <RETURN_TYPE> task;

            try
            {
                task = webMethodsCaller.CallWebMethodAsync <RETURN_TYPE>(
                    webMethodName,
                    typeof(INTERFACE_TYPE),
                    typeof(RETURN_TYPE),
                    requestParameters,
                    soapVersion);
            }
            catch (MissingMethodException)
            {
                task = webMethodsCaller.CallWebMethodAsyncBeginEnd <RETURN_TYPE>(
                    webMethodName,
                    typeof(INTERFACE_TYPE),
                    typeof(RETURN_TYPE),
                    requestParameters,
                    soapVersion);
            }

            return(task);
        }
Beispiel #2
0
        //------------------------------------------
        // WCF METHODS WHICH RETURN A VALUE
        //------------------------------------------

        public static Task <RETURN_TYPE> CallWebMethodAsync <RETURN_TYPE, INTERFACE_TYPE>(CSHTML5_ClientBase <INTERFACE_TYPE> clientBase, string methodName, Dictionary <string, Tuple <Type, object> > requestParameters) where INTERFACE_TYPE : class
        {
#if !FOR_DESIGN_TIME
            // Remove the word "Async" from the method name (this is because the method called on the server's side is the one without "Async" at the end)
            if (methodName.EndsWith("Async")) //should always be the case
            {
                methodName = methodName.Remove(methodName.Length - 5);
            }

            // Call the web method:
            var webMethodsCaller = new CSHTML5_ClientBase <INTERFACE_TYPE> .WebMethodsCaller(clientBase.INTERNAL_RemoteAddressAsString);

            return(webMethodsCaller.CallWebMethodAsync <RETURN_TYPE>(methodName, typeof(INTERFACE_TYPE), typeof(RETURN_TYPE), requestParameters));
#else
            return(null);
#endif
        }