public override IMessage Invoke(IMessage msg)
        {
            T t = ChannelFactoryCreator.Create <T>(this.configurationPath, this.endpointName).CreateChannel();
            IMethodCallMessage   methodCallMessage = (IMethodCallMessage)msg;
            IMethodReturnMessage methodReturnMessage;

            object[] array = new object[methodCallMessage.Args.Length];
            methodCallMessage.Args.CopyTo(array, 0);
            //ServiceProxyFactory.GetEndpointAddress<T>(this.configurationPath, this.endpointName);
            try
            {
                object ret          = methodCallMessage.MethodBase.Invoke(t, array);
                int    outArgsCount = array.Length;
                methodReturnMessage = new ReturnMessage(ret, array, outArgsCount, methodCallMessage.LogicalCallContext, methodCallMessage);
                var communicationObject = t as ICommunicationObject;
                if (communicationObject != null)
                {
                    communicationObject.Close();
                }
            }
            catch (CommunicationException e)
            {
                var communicationObject = t as ICommunicationObject;
                if (communicationObject != null)
                {
                    communicationObject.Abort();
                }
                methodReturnMessage = new ReturnMessage(e, methodCallMessage);
            }
            catch (TimeoutException e2)
            {
                var communicationObject = t as ICommunicationObject;
                if (communicationObject != null)
                {
                    communicationObject.Abort();
                }
                methodReturnMessage = new ReturnMessage(e2, methodCallMessage);
            }
            catch (System.Exception e3)
            {
                var communicationObject = t as ICommunicationObject;
                if (communicationObject != null)
                {
                    communicationObject.Abort();
                }
                methodReturnMessage = new ReturnMessage(e3, methodCallMessage);
            }
            return(methodReturnMessage);
        }
 public static string GetEndpointAddress <T>(string configurationPath, string endpointName)
 {
     return(ChannelFactoryCreator.Create <T>(configurationPath, endpointName).Endpoint.Address.Uri.ToString());
 }