Example #1
0
        public static RETURN_TYPE EndCallWebMethod <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 "End" from the method name (this is because the method called on the server's side is the one without "End")
            if (methodName.StartsWith("End")) //should always be the case
            {
                methodName = methodName.Substring(3);
            }

            // Read the XML result from the parameters:
            System.IAsyncResult  asyncResult          = (System.IAsyncResult)requestParameters["result"].Item2;
            WebMethodAsyncResult webMethodAsyncResult = (WebMethodAsyncResult)asyncResult;
            string xmlReturnedFromTheServer           = webMethodAsyncResult.XmlReturnedFromTheServer;

            // Call "EndCallWebMethod" to deserialize the result:
            var webMethodsCaller = new CSHTML5_ClientBase <INTERFACE_TYPE> .WebMethodsCaller(clientBase.INTERNAL_RemoteAddressAsString);

            RETURN_TYPE result = webMethodsCaller.EndCallWebMethod <RETURN_TYPE>(methodName, typeof(INTERFACE_TYPE), xmlReturnedFromTheServer);

            // Return the deserialized result:
            return(result);
#else
            return(default(RETURN_TYPE));
#endif
        }
Example #2
0
        public static object EndCallWebMethod <INTERFACE_TYPE>(
            string endpointAddress,
            string webMethodName,
            Type methodReturnType,
            IDictionary <string, object> requestParameters,
            string soapVersion) where INTERFACE_TYPE : class
        {
            // Read the XML result from the parameters
            IAsyncResult         asyncResult          = (IAsyncResult)requestParameters["result"];
            WebMethodAsyncResult webMethodAsyncResult = (WebMethodAsyncResult)asyncResult;
            string xmlReturnedFromTheServer           = webMethodAsyncResult.XmlReturnedFromTheServer;

            // Call "EndCallWebMethod" to deserialize the result
            var webMethodsCaller = new CSHTML5_ClientBase <INTERFACE_TYPE> .WebMethodsCaller(endpointAddress);

            object result = webMethodsCaller.EndCallWebMethod(
                webMethodName,
                typeof(INTERFACE_TYPE),
                methodReturnType,
                xmlReturnedFromTheServer,
                soapVersion);

            // Return the deserialized result
            return(result);
        }