Esempio n. 1
0
        private static IChannelFactory <TService> CreateChannelFactory <TService>(Uri uri) where TService : class
        {
            var binding      = (NetTcpBinding)CreateDefaultEndpointBinding(uri);
            var securityMode = ServiceSecurityMode.GetSecurityModeFromConfig();

            binding.SetBindingSecurity(securityMode);
            binding.MaxBufferSize          = 2147483647;
            binding.MaxReceivedMessageSize = 65536;
            binding.CloseTimeout           = new TimeSpan(0, 5, 0);
            //updated service RecieveTimeout to 3 minutes instead of default
            binding.ReceiveTimeout = TimeSpan.FromMinutes(3);
#if DEBUG
            binding.SendTimeout    = TimeSpan.MaxValue;
            binding.OpenTimeout    = TimeSpan.MaxValue;
            binding.ReceiveTimeout = TimeSpan.MaxValue;
            binding.CloseTimeout   = TimeSpan.MaxValue;
#endif

            binding.EnableTransactionFlowAndReliableMessaging();
            var serviceUriBuilder = new UriBuilder(uri);
            serviceUriBuilder.Path = string.Format("{0}/{1}", serviceUriBuilder.Path, securityMode.PathExtension);
            var address = CreateEndpointAddress(serviceUriBuilder.Uri, null);

            var cf = new ChannelFactory <TService>(binding, address);
            cf.AddGenericResolver();
            cf.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

            var certMode = securityMode as X509CertificateServiceSecurityMode;
            if (certMode != null)
            {
                cf.Credentials.ClientCertificate.Certificate = certMode.TransportCertificate;
            }
            return(cf);
        }
Esempio n. 2
0
        public static I CreateInstance <S, I>() where I : class
            where S : class, I
        {
            EndpointAddress    address = GetAddress <S, I>();
            ChannelFactory <I> factory = new ChannelFactory <I>(Binding, address);

            factory.AddGenericResolver();

            return(factory.CreateChannel());
        }
Esempio n. 3
0
        internal static I CreateInstance <S, I>(IServiceBehavior serviceBehavior) where I : class
            where S : class, I
        {
            EndpointAddress    address = GetAddress <S, I>(serviceBehavior, Binding as NetNamedPipeContextBinding);
            ChannelFactory <I> factory = new ChannelFactory <I>(Binding, address);

            factory.AddGenericResolver(defaultGenericResolverTypes);

            return(factory.CreateChannel());
        }
Esempio n. 4
0
        public static I CreateInstance <S, I>(IServiceBehavior serviceBehavior, IEndpointBehavior clientBehavior) where I : class
            where S : class, I
        {
            EndpointAddress    address = GetAddress <S, I>(serviceBehavior, Binding as NetNamedPipeContextBinding);
            ChannelFactory <I> factory = new ChannelFactory <I>(Binding, address);

            factory.AddGenericResolver();
            factory.Endpoint.EndpointBehaviors.Add(clientBehavior);

            return(factory.CreateChannel());
        }
Esempio n. 5
0
        internal static I CreateInstance <S, I>(IServiceBehavior serviceBehavior,
                                                NetNamedPipeContextBinding proxyBinding,
                                                NetNamedPipeContextBinding serviceBinding) where I : class
            where S : class, I
        {
            Debug.Assert(proxyBinding != null);
            Debug.Assert(serviceBinding != null);
            EndpointAddress    address = GetAddress <S, I>(serviceBehavior, serviceBinding);
            ChannelFactory <I> factory = new ChannelFactory <I>(proxyBinding, address);

            factory.AddGenericResolver();

            return(factory.CreateChannel());
        }
Esempio n. 6
0
        internal static ChannelFactory <I> InitializeInstance <S, I>(IServiceBehavior serviceBehavior,
                                                                     IEndpointBehavior clientBehavior,
                                                                     NetNamedPipeContextBinding proxyBinding,
                                                                     NetNamedPipeContextBinding serviceBinding) where I : class
            where S : class, I
        {
            if (serviceBinding == null)
            {
                serviceBinding = Binding as NetNamedPipeContextBinding;
            }
            EndpointAddress    address = GetAddress <S, I>(serviceBehavior, serviceBinding);
            ChannelFactory <I> factory = new ChannelFactory <I>(proxyBinding, address);

            factory.AddGenericResolver(defaultGenericResolverTypes);
            factory.Endpoint.EndpointBehaviors.Add(clientBehavior);

            return(factory);
        }