public IDXVCSService CreateService(string serviceUrl)
        {
            if (isServiceRegistered)
            {
                try {
                    int version = service.GetServiceVersion();
                    return(service);
                }
                catch {
                }
            }
            EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(serviceUrl), new SpnEndpointIdentity(String.Empty));
            ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress);
            ChannelFactory <IDXVCSService> factory = new Factory(point);

            factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
            IDXVCSService   newService = factory.CreateChannel();
            IContextChannel newChannel = (IContextChannel)newService;

            newChannel.OperationTimeout = TimeSpan.MaxValue;
            newChannel.Open();
            service             = newService;
            isServiceRegistered = true;
            service             = new ServiceWrapper(newService);
            return(service);
        }
        public UserNameCertificateBinding()
        {
            //add  security
               // var securityElement =
            //   SecurityBindingElement.CreateUserNameForCertificateBindingElement();

            var securityElement = new SymmetricSecurityBindingElement();

            var x509TokenParameters = new X509SecurityTokenParameters();
            // how to find certificate
            // this will be used by securitymanager to find the certificate when create x509security tokens
            //x509TokenParameters.X509ReferenceStyle = X509KeyIdentifierClauseType.Thumbprint;

            //The token is never included in messages but is referenced. The token must be known to the recipient out of band
            x509TokenParameters.InclusionMode = SecurityTokenInclusionMode.Never;
            securityElement.ProtectionTokenParameters = x509TokenParameters;

            securityElement.EndpointSupportingTokenParameters.
                SignedEncrypted.Add(new UserNameSecurityTokenParameters());

            securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11;

            securityElement.RequireSignatureConfirmation = true;

            Elements.Add(securityElement);

            // Message Encoding
            var textEncoding = new GZipMessageEncodingBindingElement();
            textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10;
            Elements.Add(textEncoding);

            // Transport
            Elements.Add(new HttpTransportBindingElement());
        }
 public InsecureGZipBasicHttpBinding()
 {
     httpTransport       = new HttpTransportBindingElement();
     textMessageEncoding = new TextMessageEncodingBindingElement {
         MessageVersion = MessageVersion.Soap11
     };
     compressionMessageEncoding = new GZipMessageEncodingBindingElement(textMessageEncoding);
 }
Beispiel #4
0
        public IDXVCSService GetService(string serviceUrl)
        {
            EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(serviceUrl), new SpnEndpointIdentity(String.Empty));
            ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress, typeof(IDXVCSService));
            ChannelFactory <IDXVCSService> factory = new Factory(point);

            factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
            IDXVCSService   newService = factory.CreateChannel();
            IContextChannel newChannel = (IContextChannel)newService;

            newChannel.OperationTimeout = TimeSpan.FromSeconds(10);
            newChannel.Open();
            return(new ServiceWrapper(newService));
        }
Beispiel #5
0
        public static Binding CreateTcpBinding()
        {
            var binMessageElement = new BinaryMessageEncodingBindingElement();

            binMessageElement.ReaderQuotas.MaxArrayLength         = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxBytesPerRead        = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxDepth = int.MaxValue;

            var gzipElement = new GZipMessageEncodingBindingElement
            {
                InnerMessageEncodingBindingElement = binMessageElement
            };

            var tcpTransport = new TcpTransportBindingElement
            {
                MaxBufferPoolSize            = int.MaxValue,
                MaxBufferSize                = int.MaxValue,
                MaxReceivedMessageSize       = int.MaxValue,
                ChannelInitializationTimeout = TimeSpan.FromHours(12),
                PortSharingEnabled           = false,
                ListenBacklog                = int.MaxValue,
                MaxPendingConnections        = 100,
                MaxPendingAccepts            = 32,
            };
            //tcpTransport.ReaderQuotas.MaxArrayLength = int.MaxValue;
            //tcpTransport.ReaderQuotas.MaxStringContentLength = int.MaxValue;

            var binding = new CustomBinding(gzipElement, tcpTransport)
            {
                ReceiveTimeout = TimeSpan.FromHours(12),
                SendTimeout    = TimeSpan.FromHours(12),
                OpenTimeout    = TimeSpan.FromHours(12),
                CloseTimeout   = TimeSpan.FromHours(12),
            };

            //binding.ReliableSession.Enabled = false;


            //binding.Security.Mode = SecurityMode.None;
            //binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

            return(binding);
        }
Beispiel #6
0
 public static ServiceBase <IDXVCSService> ConnectWCF(string auxPath, string user, string password)
 {
     lock (services) {
         WCFService <IDXVCSService> service;
         string serviceName = string.Format("{0}#$%%$#{1}#@%%@#{2}", auxPath, string.IsNullOrEmpty(user) ? string.Empty : user, string.IsNullOrEmpty(password));
         if (!services.TryGetValue(serviceName, out service))
         {
             EndpointAddress myEndpointAddress      = new EndpointAddress(new Uri(auxPath), new SpnEndpointIdentity(String.Empty));
             ServiceEndpoint point                  = GZipMessageEncodingBindingElement.CreateEndpoint(myEndpointAddress, typeof(IDXVCSService));
             ChannelFactory <IDXVCSService> factory = new Factory <IDXVCSService>(point);
             factory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;
             if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password))
             {
                 factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(user, password);
             }
             service = new WCFService <IDXVCSService>(factory);
             services.Add(serviceName, service);
         }
         return(service);
     }
 }
Beispiel #7
0
        public static Binding CreateHttpBinding()
        {
            /*
             * var binding = new WSHttpBinding
             * {
             *  MaxBufferPoolSize = int.MaxValue,
             *  MaxReceivedMessageSize = int.MaxValue,
             *  ReliableSession = {
             *      Enabled = true
             *  },
             *  Security =
             *  {
             *      Mode = SecurityMode.None
             *  },
             *  ReaderQuotas =
             *  {
             *      MaxArrayLength = int.MaxValue,
             *      MaxStringContentLength = int.MaxValue
             *  }
             * };
             * binding.ReceiveTimeout = TimeSpan.FromHours(12);
             * binding.SendTimeout = TimeSpan.FromHours(12);
             * binding.OpenTimeout = TimeSpan.FromHours(12);
             * binding.CloseTimeout = TimeSpan.FromHours(12);
             *
             * binding.MaxReceivedMessageSize = int.MaxValue;
             * binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
             * binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
             * binding.Security.Mode = SecurityMode.None;
             * binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
             */

            var binMessageElement = new BinaryMessageEncodingBindingElement();

            binMessageElement.ReaderQuotas.MaxArrayLength         = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxStringContentLength = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxBytesPerRead        = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxDepth = int.MaxValue;
            binMessageElement.ReaderQuotas.MaxNameTableCharCount = int.MaxValue;

            var gzipElement = new GZipMessageEncodingBindingElement
            {
                InnerMessageEncodingBindingElement = binMessageElement
            };

            var reliableElement = new ReliableSessionBindingElement()
            {
                MaxPendingChannels = 16384,
                Ordered            = true
            };
            Boolean _configProxy = false;

            if (App.Configs.UseProxy == CONSTANTS.Yes)
            {
                _configProxy = true;
            }

            var httpTransport = new HttpTransportBindingElement
            {
                KeepAliveEnabled       = true,
                MaxBufferPoolSize      = int.MaxValue,
                MaxBufferSize          = int.MaxValue,
                MaxReceivedMessageSize = int.MaxValue,
                UseDefaultWebProxy     = _configProxy,
            };


            //tcpTransport.ReaderQuotas.MaxArrayLength = int.MaxValue;
            //tcpTransport.ReaderQuotas.MaxStringContentLength = int.MaxValue;

            var binding = new CustomBinding(reliableElement, gzipElement, httpTransport)
            {
                ReceiveTimeout = TimeSpan.FromHours(12),
                SendTimeout    = TimeSpan.FromHours(12),
                OpenTimeout    = TimeSpan.FromHours(12),
                CloseTimeout   = TimeSpan.FromHours(12)
            };

            //binding.ReliableSession.Enabled = false;


            //binding.Security.Mode = SecurityMode.None;
            //binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;

            return(binding);
        }
 public FileTransportBinding()
 {
     this.messageEncodingBindingElement = new GZipMessageEncodingBindingElement();
     this.transportBindingElement = new FileTransportBindingElement();
 }
 //Called by the WCF to create the binding element
 protected override BindingElement CreateBindingElement()
 {
     GZipMessageEncodingBindingElement bindingElement = new GZipMessageEncodingBindingElement();
     this.ApplyConfiguration(bindingElement);
     return bindingElement;
 }