Exemplo n.º 1
0
        internal void WSHttpRequestReplyWithTransportMessageCertificateEchoString()
        {
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateHttpsWebHostBuilder <WSHttpTransportWithMessageCredentialWithCertificate>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.TransportWithMessageCredential);
                wsHttpBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.Certificate;
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("https://localhost:8443/WSHttpWcfService/basichttp.svc")));
                ClientCredentials clientCredentials = (ClientCredentials)factory.Endpoint.EndpointBehaviors[typeof(ClientCredentials)];
                clientCredentials.ClientCertificate.Certificate = ServiceHelper.GetServiceCertificate();
                factory.Credentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication
                {
                    CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None
                };
                ClientContract.IEchoService channel = factory.CreateChannel();
                ((IChannel)channel).Open();
                string result = channel.EchoString(testString);
                Assert.Equal(testString, result);
                ((IChannel)channel).Close();
                Console.WriteLine("read ");
            }
        }
Exemplo n.º 2
0
        // http://www.programminghelp.com/programming/dotnet/wcf-creating-and-implementing-a-service-in-c/
        static void Main(string[] args)
        {
            string address = "http://localhost:41433/WCFService1/FTR2LO_InternalService";
            System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();
            binding.Name = "WSHttpBinding_IFTR2LO"; // not sure if this is necessary.
            System.ServiceModel.EndpointAddress endpointAddress = new System.ServiceModel.EndpointAddress(address);
            FTR2LOClient client = new FTR2LOClient(binding, endpointAddress);

            //FTR2LOClient client = new FTR2LOClient();
            bool _isconnectedtoFTR2LO = false;
            Console.Write("Is connected to FTR2LO: ");
            try
            {
                _isconnectedtoFTR2LO = client.IsConnectedToFTR2LO();
            }
            catch (Exception)
            {
                //Console.WriteLine("Error");
            }
            Console.WriteLine(_isconnectedtoFTR2LO.ToString());

            if (_isconnectedtoFTR2LO)
            {
                Console.WriteLine("Is connected to FTR: " + client.IsConnectedToFTR());
                int status = client.IPingFTR();
                Console.WriteLine("IPingFTR: " + status.ToString());
                Console.WriteLine("IPingFTRToString: " + client.IPingFTRToString(status));
            }
            if (client.State == System.ServiceModel.CommunicationState.Opened)
                client.Close();
            Console.WriteLine();
            Console.WriteLine("Press the ENTER key to terminate client.");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public void WSHttpRequestReplyWithTransportMessageEchoStringDemuxFailure()
        {
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateHttpsWebHostBuilder <WSHttpTransportWithMessageCredentialWithUserNameExpire>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.TransportWithMessageCredential);
                wsHttpBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.UserName;
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("https://localhost:8443/WSHttpWcfService/basichttp.svc")));
                ClientCredentials clientCredentials = (ClientCredentials)factory.Endpoint.EndpointBehaviors[typeof(ClientCredentials)];
                clientCredentials.UserName.UserName = "******";
                clientCredentials.UserName.Password = "******";
                factory.Credentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication
                {
                    CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None
                };
                ClientContract.IEchoService channel = factory.CreateChannel();
                ((IChannel)channel).Open();
                Thread.Sleep(6000);
                try
                {
                    channel.EchoString(testString);
                }catch (Exception ex)
                {
                    Assert.True(typeof(System.ServiceModel.FaultException).Equals(ex.InnerException.GetType()));
                    Assert.Contains("expired security context token", ex.InnerException.Message);
                }
            }
        }
Exemplo n.º 4
0
        public void WSHttpRequestReplyEchoStringTransportSecurity()
        {
            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateCertificate);
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateHttpsWebHostBuilder <WSHttpTransportSecurityOnly>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.Transport);
                wsHttpBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.None;
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("https://localhost:8443/WSHttpWcfService/basichttp.svc")));
                factory.Credentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication
                {
                    CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None
                };
                ClientContract.IEchoService channel = factory.CreateChannel();
                ((IChannel)channel).Open();
                string result = channel.EchoString(testString);
                Assert.Equal(testString, result);
                Console.WriteLine("read ");
                ((IChannel)channel).Close();
            }
        }
Exemplo n.º 5
0
        public void WSHttpRequestReplyWithTransportMessageEchoString()
        {
            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateCertificate);
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateHttpsWebHostBuilder <WSHttpTransportWithMessageCredentialWithUserName>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.TransportWithMessageCredential);
                wsHttpBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.UserName;
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("https://localhost:8443/WSHttpWcfService/basichttp.svc")));
                ClientCredentials clientCredentials = (ClientCredentials)factory.Endpoint.EndpointBehaviors[typeof(ClientCredentials)];
                clientCredentials.UserName.UserName = "******";
                clientCredentials.UserName.Password = "******";
                factory.Credentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication
                {
                    CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None
                };
                ClientContract.IEchoService channel = factory.CreateChannel();
                ((IChannel)channel).Open();
                string result = channel.EchoString(testString);
                Assert.Equal(testString, result);
                Thread.Sleep(5000);

                ((IChannel)channel).Close();
                Console.WriteLine("read ");
            }
        }
Exemplo n.º 6
0
        // [Fact, Description("transport-security-with-certificate-authentication")]
        //TODO set up in container, tested locally and this works
        internal void WSHttpRequestReplyWithTransportMessageCertificateEchoString()
        {
            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateCertificate);
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateHttpsWebHostBuilder <WSHttpTransportWithMessageCredentialWithCertificate>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.TransportWithMessageCredential);
                wsHttpBinding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.Certificate;
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("https://localhost:8443/WSHttpWcfService/basichttp.svc")));
                ClientCredentials clientCredentials = (ClientCredentials)factory.Endpoint.EndpointBehaviors[typeof(ClientCredentials)];
                clientCredentials.ClientCertificate.SetCertificate(
                    StoreLocation.LocalMachine,
                    StoreName.My, X509FindType.FindBySubjectName
                    , "birojtestcert"
                    );

                ClientContract.IEchoService channel = factory.CreateChannel();
                ((IChannel)channel).Open();
                string result = channel.EchoString(testString);
                Assert.Equal(testString, result);
                ((IChannel)channel).Close();
                Console.WriteLine("read ");
            }
        }
Exemplo n.º 7
0
        // Creates MDS service client proxy.
        private static ServiceClient GetClientProxy(string targetURL)
        {
            // Creates an endpoint address using the URL.
            System.ServiceModel.EndpointAddress endptAddress = new System.ServiceModel.EndpointAddress(targetURL);

            // Creates and configures the WS Http binding.
            System.ServiceModel.WSHttpBinding wsBinding = new System.ServiceModel.WSHttpBinding();

            // Creates and returns the client proxy.
            return(new ServiceClient(wsBinding, endptAddress));
        }
Exemplo n.º 8
0
        public void WSHttpRequestReplyEchoString()
        {
            string   testString = new string('a', 3000);
            IWebHost host       = ServiceHelper.CreateWebHostBuilder <WSHttpNoSecurity>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.WSHttpBinding wsHttpBinding = ClientHelper.GetBufferedModeWSHttpBinding(System.ServiceModel.SecurityMode.None);
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.IEchoService>(wsHttpBinding,
                                                                                                   new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/WSHttpWcfService/basichttp.svc")));
                ClientContract.IEchoService channel = factory.CreateChannel();
                string result = channel.EchoString(testString);
                Assert.Equal(testString, result);
            }
        }
Exemplo n.º 9
0
        // http://www.programminghelp.com/programming/dotnet/wcf-creating-and-implementing-a-service-in-c/
        static void Main(string[] args)
        {
            string address = "http://localhost:41433/WCFService1/FTR2LO_InternalService";

            System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();
            binding.Name = "WSHttpBinding_IFTR2LO"; // not sure if this is necessary.
            System.ServiceModel.EndpointAddress endpointAddress = new System.ServiceModel.EndpointAddress(address);
            FTR2LOClient client = new FTR2LOClient(binding, endpointAddress);

            //FTR2LOClient client = new FTR2LOClient();
            bool _isconnectedtoFTR2LO = false;

            Console.Write("Is connected to FTR2LO: ");
            try
            {
                _isconnectedtoFTR2LO = client.IsConnectedToFTR2LO();
            }
            catch (Exception)
            {
                //Console.WriteLine("Error");
            }
            Console.WriteLine(_isconnectedtoFTR2LO.ToString());

            if (_isconnectedtoFTR2LO)
            {
                Console.WriteLine("Is connected to FTR: " + client.IsConnectedToFTR());
                int status = client.IPingFTR();
                Console.WriteLine("IPingFTR: " + status.ToString());
                Console.WriteLine("IPingFTRToString: " + client.IPingFTRToString(status));
            }
            if (client.State == System.ServiceModel.CommunicationState.Opened)
            {
                client.Close();
            }
            Console.WriteLine();
            Console.WriteLine("Press the ENTER key to terminate client.");
            Console.ReadLine();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Construct method
        /// </summary>
        private void Construct()
        {
            try
            {
                this.config = Configuration.GetNewInstance();

                //this.importWorker = new BackgroundWorker();
                //this.importWorker.WorkerSupportsCancellation = true;

                //this.requestWorker = new BackgroundWorker();
                //this.requestWorker.WorkerSupportsCancellation = true;

                if (config.Settings.WebServiceAuthMode == 1) // Windows Authentication
                {
                    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                    binding.Name                   = "BasicHttpBinding";
                    binding.CloseTimeout           = new TimeSpan(0, 1, 0);
                    binding.OpenTimeout            = new TimeSpan(0, 1, 0);
                    binding.ReceiveTimeout         = new TimeSpan(0, 10, 0);
                    binding.SendTimeout            = new TimeSpan(0, 1, 0);
                    binding.AllowCookies           = false;
                    binding.BypassProxyOnLocal     = false;
                    binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;

                    binding.MaxBufferPoolSize      = config.Settings.WebServiceMaxBufferPoolSize;
                    binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize;

                    binding.MessageEncoding       = System.ServiceModel.WSMessageEncoding.Text;
                    binding.TextEncoding          = System.Text.Encoding.UTF8;
                    binding.TransferMode          = System.ServiceModel.TransferMode.Buffered;
                    binding.UseDefaultWebProxy    = true;
                    binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;
                    binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength;
                    binding.ReaderQuotas.MaxArrayLength         = config.Settings.WebServiceReaderMaxArrayLength;
                    binding.ReaderQuotas.MaxBytesPerRead        = config.Settings.WebServiceReaderMaxBytesPerRead;
                    binding.ReaderQuotas.MaxNameTableCharCount  = config.Settings.WebServiceReaderMaxNameTableCharCount;

                    binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType  = System.ServiceModel.HttpProxyCredentialType.None;
                    binding.Security.Transport.Realm = string.Empty;

                    binding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName;

                    System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);

                    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();
                    binding.Name                   = "WSHttpBinding";
                    binding.CloseTimeout           = new TimeSpan(0, 1, 0);
                    binding.OpenTimeout            = new TimeSpan(0, 1, 0);
                    binding.ReceiveTimeout         = new TimeSpan(0, 10, 0);
                    binding.SendTimeout            = new TimeSpan(0, 1, 0);
                    binding.BypassProxyOnLocal     = false;
                    binding.TransactionFlow        = false;
                    binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;

                    binding.MaxBufferPoolSize      = config.Settings.WebServiceMaxBufferPoolSize;
                    binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize;

                    binding.MessageEncoding    = System.ServiceModel.WSMessageEncoding.Text;
                    binding.TextEncoding       = System.Text.Encoding.UTF8;
                    binding.UseDefaultWebProxy = true;
                    binding.AllowCookies       = false;

                    binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;
                    binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength;
                    binding.ReaderQuotas.MaxArrayLength         = config.Settings.WebServiceReaderMaxArrayLength;
                    binding.ReaderQuotas.MaxBytesPerRead        = config.Settings.WebServiceReaderMaxBytesPerRead;
                    binding.ReaderQuotas.MaxNameTableCharCount  = config.Settings.WebServiceReaderMaxNameTableCharCount;

                    binding.ReliableSession.Ordered           = true;
                    binding.ReliableSession.InactivityTimeout = new TimeSpan(0, 10, 0);
                    binding.ReliableSession.Enabled           = false;

                    binding.Security.Mode = System.ServiceModel.SecurityMode.Message;
                    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType  = System.ServiceModel.HttpProxyCredentialType.None;
                    binding.Security.Transport.Realm = string.Empty;
                    binding.Security.Message.ClientCredentialType       = System.ServiceModel.MessageCredentialType.Windows;
                    binding.Security.Message.NegotiateServiceCredential = true;

                    System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);
                }
                this.wfList = new List <WebFieldData>();
            }
            catch (Exception ex)
            {
                //SetStatusMessage("Error: Web service information was not found.");
            }
        }
Exemplo n.º 11
0
 private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
 {
     if ((endpointConfiguration == EndpointConfiguration.defaultEndpoint))
     {
         System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.defaultBasic))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.basicHttpEndpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.basicHttpsEndpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.Transport;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpsoap11Endpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpsoap12Endpoint))
     {
         System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpbinaryEndpoint))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpssoap11Endpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.Transport;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpssoap12Endpoint))
     {
         System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.SecurityMode.Transport;
         result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.nettcpdefaultBinding))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.nettcpdefaultBinding1))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.Security.Mode          = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
 }
Exemplo n.º 12
0
        private void update_service_status_area_Job()
        {
            Update_labelDebugInfo("GUI updatejob started: " + DateTime.Now.ToString());
            timer1.Stop();

            // Lights Out small icon
            string LOstatus = GetWindowsServiceStatus(TopLevelTabHelpers.LO_ServiceName);

            Update_label_actual_LOstatus(LOstatus);
            if (LOstatus == "Running")
            {
                Visible_loadingCircle_LO(false);
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);
            }
            else if (LOstatus == "Not installed.")
            {
                Visible_loadingCircle_LO(false);
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
            }
            else
            {
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning_16x16_72);
                Visible_loadingCircle_LO(false);
            }

            // FTR2LO and FTR icon plus large icon
            bool         _isconnectedtoFTR2LO = false;
            int          _status    = -3;
            string       _FTRStatus = "Unknown (1)";
            string       _address   = "http://localhost:41433/WCFService1/FTR2LO_InternalService";
            FTR2LOClient client     = null;

            System.ServiceModel.WSHttpBinding   binding         = null;
            System.ServiceModel.EndpointAddress endpointAddress = null;

            try
            {
                binding         = new System.ServiceModel.WSHttpBinding();
                binding.Name    = "WSHttpBinding_IFTR2LO"; // not sure if this is necessary.
                endpointAddress = new System.ServiceModel.EndpointAddress(_address);
                System.TimeSpan receiveTimeout = new System.TimeSpan();
                TimeSpan.TryParse("00:10:00", out receiveTimeout);
                binding.ReceiveTimeout = receiveTimeout;
                //FTR2LOClient client = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("A really crazy exception has occured:\n" + ex.ToString());
            }
            try
            {
                client = new FTR2LOClient(binding, endpointAddress);
                _isconnectedtoFTR2LO = client.IsConnectedToFTR2LO();
                _status    = client.IPingFTR();
                _FTRStatus = client.IPingFTRToString(_status);
            }
            catch (Exception)
            {
                //in this case, display error for FTR2LO and leave FTR loadingcircle
                Update_label_actual_server_status("Error: Not connected");
                Update_label_actual_FTRstatus("Unknown");
                Update_pictureBoxFTR2LO_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
                Visible_loadingCircle_FTR2LO(false);
                Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError);
                Visible_loadingCircle1(false);
            }
            finally
            {
                if (client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    client.Close();
                }
            }


            if (_isconnectedtoFTR2LO)
            {
                Visible_loadingCircle_FTR2LO(false);
                Update_label_actual_server_status("Connected");
                Update_pictureBoxFTR2LO_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);

                // FTRL2LO icon and large icon
                Update_label_actual_FTRstatus(_FTRStatus);
                if (_status == 0)
                {
                    Visible_loadingCircle_FTR(false);
                    Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);
                    Visible_loadingCircle1(false);
                    Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK);
                }
                else
                {
                    Visible_loadingCircle_FTR(false);
                    Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning_16x16_72);
                    Visible_loadingCircle1(false);
                    Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning);
                }
            }
            else
            {
                Update_label_actual_server_status("Not connected");
                Visible_loadingCircle1(false);
                Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
                Update_label_actual_FTRstatus("Unknown");
            }
            timer1.Start();
            Update_labelDebugInfo("GUI update finished: " + DateTime.Now.ToString());
        }
Exemplo n.º 13
0
        /// <summary>
        /// Construct method
        /// </summary>
        private void Construct()
        {
            try
            {
                this.config = Configuration.GetNewInstance();

                //this.importWorker = new BackgroundWorker();
                //this.importWorker.WorkerSupportsCancellation = true;

                //this.requestWorker = new BackgroundWorker();
                //this.requestWorker.WorkerSupportsCancellation = true;

                if (config.Settings.WebServiceAuthMode == 1) // Windows Authentication
                {
                    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                    binding.Name = "BasicHttpBinding";
                    binding.CloseTimeout = new TimeSpan(0, 1, 0);
                    binding.OpenTimeout = new TimeSpan(0, 1, 0);
                    binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                    binding.SendTimeout = new TimeSpan(0, 1, 0);
                    binding.AllowCookies = false;
                    binding.BypassProxyOnLocal = false;
                    binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;

                    binding.MaxBufferPoolSize = config.Settings.WebServiceMaxBufferPoolSize;
                    binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize;

                    binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text;
                    binding.TextEncoding = System.Text.Encoding.UTF8;
                    binding.TransferMode = System.ServiceModel.TransferMode.Buffered;
                    binding.UseDefaultWebProxy = true;
                    binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;
                    binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength;
                    binding.ReaderQuotas.MaxArrayLength = config.Settings.WebServiceReaderMaxArrayLength;
                    binding.ReaderQuotas.MaxBytesPerRead = config.Settings.WebServiceReaderMaxBytesPerRead;
                    binding.ReaderQuotas.MaxNameTableCharCount = config.Settings.WebServiceReaderMaxNameTableCharCount;

                    binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None;
                    binding.Security.Transport.Realm = string.Empty;

                    binding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName;

                    System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);

                    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();
                    binding.Name = "WSHttpBinding";
                    binding.CloseTimeout = new TimeSpan(0, 1, 0);
                    binding.OpenTimeout = new TimeSpan(0, 1, 0);
                    binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                    binding.SendTimeout = new TimeSpan(0, 1, 0);
                    binding.BypassProxyOnLocal = false;
                    binding.TransactionFlow = false;
                    binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;

                    binding.MaxBufferPoolSize = config.Settings.WebServiceMaxBufferPoolSize;
                    binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize;

                    binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text;
                    binding.TextEncoding = System.Text.Encoding.UTF8;
                    binding.UseDefaultWebProxy = true;
                    binding.AllowCookies = false;

                    binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;
                    binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength;
                    binding.ReaderQuotas.MaxArrayLength = config.Settings.WebServiceReaderMaxArrayLength;
                    binding.ReaderQuotas.MaxBytesPerRead = config.Settings.WebServiceReaderMaxBytesPerRead;
                    binding.ReaderQuotas.MaxNameTableCharCount = config.Settings.WebServiceReaderMaxNameTableCharCount;

                    binding.ReliableSession.Ordered = true;
                    binding.ReliableSession.InactivityTimeout = new TimeSpan(0, 10, 0);
                    binding.ReliableSession.Enabled = false;

                    binding.Security.Mode = System.ServiceModel.SecurityMode.Message;
                    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None;
                    binding.Security.Transport.Realm = string.Empty;
                    binding.Security.Message.ClientCredentialType = System.ServiceModel.MessageCredentialType.Windows;
                    binding.Security.Message.NegotiateServiceCredential = true;

                    System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);
                }
                this.wfList = new List<WebFieldData>();
            }
            catch (Exception ex)
            {
                //SetStatusMessage("Error: Web service information was not found.");
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type.
        /// </summary>
        /// <remarks>
        /// This function might get more important if other WCF bingis are supported.
        /// All settings to a specific binding shuld be made here.
        /// All binding are probably not needed.
        /// </remarks>
        /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param>
        /// <returns>The new configured binding element.</returns>
        public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint)
        {
            if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary)
                return null;

            System.ServiceModel.Channels.Binding ret = null;

            WCFBinding bindingEnum = endPoint.Binding;

            switch (bindingEnum)
            {
                #region BasicHttpBinding
                case WCFBinding.BasicHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.BasicHttpBinding bhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                bhb = new System.ServiceModel.BasicHttpBinding();
                                bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                bhb.MaxReceivedMessageSize = Int32.MaxValue;
                                bhb.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = bhb;
                        break;
                    }
                #endregion
                #region MsmqIntegrationBinding
                case WCFBinding.MsmqIntegrationBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                                mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = mib;
                        break;
                    }
                #endregion
                #region NetMsmqBinding
                case WCFBinding.NetMsmqBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetMsmqBinding nmb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nmb = new System.ServiceModel.NetMsmqBinding();
                                nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nmb;
                        break;
                    }
                #endregion
                #region NetNamedPipeBinding
                case WCFBinding.NetNamedPipeBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetNamedPipeBinding nnpb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nnpb = new System.ServiceModel.NetNamedPipeBinding();
                                nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nnpb;
                        break;
                    }
                #endregion
                #region NetPeerTcpBinding
                case WCFBinding.NetPeerTcpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetPeerTcpBinding nptb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nptb = new System.ServiceModel.NetPeerTcpBinding();
                                nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nptb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nptb;
                        break;
                    }
                #endregion
                #region NetTcpBinding
                case WCFBinding.NetTcpBinding:
                    {
                        System.ServiceModel.NetTcpBinding ntb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                ntb = new System.ServiceModel.NetTcpBinding();
                                ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                ntb.MaxReceivedMessageSize = Int32.MaxValue;
                                ntb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = ntb;
                        break;
                    }
                #endregion
                #region WSDualHttpBinding
                case WCFBinding.WSDualHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.WSDualHttpBinding wdhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                wdhb = new System.ServiceModel.WSDualHttpBinding();
                                wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = wdhb;
                        break;
                    }
                #endregion
                #region WSFederationHttpBinding
                case WCFBinding.WSFederationHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.WSFederationHttpBinding wfhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                wfhb = new System.ServiceModel.WSFederationHttpBinding();
                                wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = wfhb;
                        break;
                    }
                #endregion
                #region WSHttpBinding
                case WCFBinding.WSHttpBinding:
                    {
                        System.ServiceModel.WSHttpBinding whb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                whb = new System.ServiceModel.WSHttpBinding();
                                whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                whb.MaxReceivedMessageSize = Int32.MaxValue;
                                whb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = whb;
                        break;
                    }
                #endregion
            }

            return ret;
        }
Exemplo n.º 15
0
        // Creates MDS service client proxy.
        private static ServiceClient GetClientProxy(string targetURL)
        {
            // Creates an endpoint address using the URL.
            System.ServiceModel.EndpointAddress endptAddress = new System.ServiceModel.EndpointAddress(targetURL);

            // Creates and configures the WS Http binding.
            System.ServiceModel.WSHttpBinding wsBinding = new System.ServiceModel.WSHttpBinding();

            // Creates and returns the client proxy.
            return new ServiceClient(wsBinding, endptAddress);
        }
Exemplo n.º 16
0
        private static void OpenConnection(common.configuration.wsConnectionInfo wsInfo)
        {
            if (_myClient != null)
            {
                _myClient.Abort();
            }
            _myClient = new ServiceReference1.StockServiceClient();

            System.ServiceModel.WSHttpBinding binding = (_myClient.Endpoint.Binding as System.ServiceModel.WSHttpBinding);

            binding.OpenTimeout  = TimeSpan.FromSeconds(wsInfo.timeoutInSecs);
            binding.CloseTimeout = TimeSpan.FromSeconds(wsInfo.timeoutInSecs);
            binding.SendTimeout  = TimeSpan.FromSeconds(wsInfo.timeoutInSecs);

            binding.MaxReceivedMessageSize = constMaxReceivedMessageSize;
            binding.ReaderQuotas.MaxStringContentLength = constMaxStringContentLength;
            binding.ReaderQuotas.MaxBytesPerRead        = constMaxBytesPerRead;

            //Proxy  must befor setting Endpoint ?
            if (wsInfo.useProxy)
            {
                //Chua loi proxy http://chrishaas.wordpress.com/2009/11/02/fixing-the-remote-server-returned-an-error-417-expectation-failed/

                ServicePointManager.Expect100Continue = false;

                if (wsInfo.useDefaultProxy)
                {
                    binding.UseDefaultWebProxy = true;
                }
                else
                {
                    if (wsInfo.proxyAddress.Trim() != "" && wsInfo.proxyPort.Trim() != "")
                    {
                        binding.ProxyAddress       = new Uri(wsInfo.proxyAddress.Trim() + ":" + wsInfo.proxyPort.Trim());
                        binding.BypassProxyOnLocal = true;
                        binding.UseDefaultWebProxy = false;
                    }
                }
            }
            //Endpoint settings
            _myClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(wsInfo.URI);
            if (wsInfo.isWindowAuthentication)
            {
                _myClient.ClientCredentials.Windows.ClientCredential.UserName = wsInfo.account;
                _myClient.ClientCredentials.Windows.ClientCredential.Password = wsInfo.password;
            }
            else
            {
                _myClient.ClientCredentials.UserName.UserName = wsInfo.account;
                _myClient.ClientCredentials.UserName.Password = wsInfo.password;
            }
            //For testing
            //_myClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:8731/wsServices/DataLibs/?wsdl");
            //_myClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost/DataLibs.svc");
            //_myClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:8731/wsServices/DataLibs");
            //_myClient.ClientCredentials.Windows.ClientCredential.UserName = "";
            //_myClient.ClientCredentials.Windows.ClientCredential.Password = "";
            //ServicePointManager.UseNagleAlgorithm = true;
            //ServicePointManager.CheckCertificateRevocationList = true;
            //ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit;

            _myClient.Open();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type.
        /// </summary>
        /// <remarks>
        /// This function might get more important if other WCF bingis are supported.
        /// All settings to a specific binding shuld be made here.
        /// All binding are probably not needed.
        /// </remarks>
        /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param>
        /// <returns>The new configured binding element.</returns>
        public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint)
        {
            if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary)
            {
                return(null);
            }

            System.ServiceModel.Channels.Binding ret = null;

            WCFBinding bindingEnum = endPoint.Binding;

            switch (bindingEnum)
            {
                #region BasicHttpBinding
            case WCFBinding.BasicHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.BasicHttpBinding bhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    bhb = new System.ServiceModel.BasicHttpBinding();
                    bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    bhb.MaxReceivedMessageSize = Int32.MaxValue;
                    bhb.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = bhb;
                break;
            }

                #endregion
                #region MsmqIntegrationBinding
            case WCFBinding.MsmqIntegrationBinding:
            {
                //WARNING: untested code
                System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                    mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = mib;
                break;
            }

                #endregion
                #region NetMsmqBinding
            case WCFBinding.NetMsmqBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetMsmqBinding nmb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nmb = new System.ServiceModel.NetMsmqBinding();
                    nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nmb;
                break;
            }

                #endregion
                #region NetNamedPipeBinding
            case WCFBinding.NetNamedPipeBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetNamedPipeBinding nnpb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nnpb = new System.ServiceModel.NetNamedPipeBinding();
                    nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nnpb;
                break;
            }

                #endregion
                #region NetPeerTcpBinding
            case WCFBinding.NetPeerTcpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetPeerTcpBinding nptb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nptb = new System.ServiceModel.NetPeerTcpBinding();
                    nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nptb.Security.Mode = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nptb;
                break;
            }

                #endregion
                #region NetTcpBinding
            case WCFBinding.NetTcpBinding:
            {
                System.ServiceModel.NetTcpBinding ntb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    ntb = new System.ServiceModel.NetTcpBinding();
                    ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    ntb.MaxReceivedMessageSize = Int32.MaxValue;
                    ntb.Security.Mode          = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = ntb;
                break;
            }

                #endregion
                #region WSDualHttpBinding
            case WCFBinding.WSDualHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.WSDualHttpBinding wdhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    wdhb = new System.ServiceModel.WSDualHttpBinding();
                    wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = wdhb;
                break;
            }

                #endregion
                #region WSFederationHttpBinding
            case WCFBinding.WSFederationHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.WSFederationHttpBinding wfhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    wfhb = new System.ServiceModel.WSFederationHttpBinding();
                    wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = wfhb;
                break;
            }

                #endregion
                #region WSHttpBinding
            case WCFBinding.WSHttpBinding:
            {
                System.ServiceModel.WSHttpBinding whb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    whb = new System.ServiceModel.WSHttpBinding();
                    whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    whb.MaxReceivedMessageSize = Int32.MaxValue;
                    whb.Security.Mode          = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = whb;
                break;
            }
                #endregion
            }


            return(ret);
        }
Exemplo n.º 18
0
        private void update_service_status_area_Job()
        {
            Update_labelDebugInfo("GUI updatejob started: " + DateTime.Now.ToString());
            timer1.Stop();

            // Lights Out small icon
            string LOstatus = GetWindowsServiceStatus(TopLevelTabHelpers.LO_ServiceName);
            Update_label_actual_LOstatus(LOstatus);
            if (LOstatus == "Running")
            {
                Visible_loadingCircle_LO(false);
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);
            }
            else if (LOstatus == "Not installed.")
            {
                Visible_loadingCircle_LO(false);
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
            }
            else
            {
                Update_pictureBoxLO_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning_16x16_72);
                Visible_loadingCircle_LO(false);
            }

            // FTR2LO and FTR icon plus large icon
            bool _isconnectedtoFTR2LO = false;
            int _status = -3;
            string _FTRStatus = "Unknown (1)";
            string _address = "http://localhost:41433/WCFService1/FTR2LO_InternalService";
            FTR2LOClient client = null;
            System.ServiceModel.WSHttpBinding binding = null;
            System.ServiceModel.EndpointAddress endpointAddress = null;

            try
            {
                binding = new System.ServiceModel.WSHttpBinding();
                binding.Name = "WSHttpBinding_IFTR2LO"; // not sure if this is necessary.
                endpointAddress = new System.ServiceModel.EndpointAddress(_address);
                System.TimeSpan receiveTimeout = new System.TimeSpan();
                TimeSpan.TryParse("00:10:00", out receiveTimeout);
                binding.ReceiveTimeout = receiveTimeout;
                //FTR2LOClient client = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("A really crazy exception has occured:\n" + ex.ToString());
            }
            try
            {
                client = new FTR2LOClient(binding, endpointAddress);
                _isconnectedtoFTR2LO = client.IsConnectedToFTR2LO();
                _status = client.IPingFTR();
                _FTRStatus = client.IPingFTRToString(_status);
            }
            catch (Exception)
            {
                //in this case, display error for FTR2LO and leave FTR loadingcircle
                Update_label_actual_server_status("Error: Not connected");
                Update_label_actual_FTRstatus("Unknown");
                Update_pictureBoxFTR2LO_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
                Visible_loadingCircle_FTR2LO(false);
                Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError);
                Visible_loadingCircle1(false);
            }
            finally
            {
                if (client.State == System.ServiceModel.CommunicationState.Opened)
                    client.Close();
            }

            if (_isconnectedtoFTR2LO)
            {
                Visible_loadingCircle_FTR2LO(false);
                Update_label_actual_server_status("Connected");
                Update_pictureBoxFTR2LO_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);

                // FTRL2LO icon and large icon
                Update_label_actual_FTRstatus(_FTRStatus);
                if (_status == 0)
                {
                    Visible_loadingCircle_FTR(false);
                    Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK__16x16_72);
                    Visible_loadingCircle1(false);
                    Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.Complete_OK);
                }
                else
                {
                    Visible_loadingCircle_FTR(false);
                    Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning_16x16_72);
                    Visible_loadingCircle1(false);
                    Update_pictureBox1_Image(ATV2LO_TopLevelTab.Properties.Resources.Warning);
                }
            }
            else
            {
                Update_label_actual_server_status("Not connected");
                Visible_loadingCircle1(false);
                Update_pictureBoxFTR_Image(ATV2LO_TopLevelTab.Properties.Resources.CriticalError_16x16_72);
                Update_label_actual_FTRstatus("Unknown");
            }
            timer1.Start();
            Update_labelDebugInfo("GUI update finished: " + DateTime.Now.ToString());
        }
Exemplo n.º 19
0
 private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
 {
     if ((endpointConfiguration == EndpointConfiguration.NetHttpOrdered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         reliableBindingElement.ReliableMessagingVersion = System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11;
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetHttpUnordered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         reliableBindingElement.Ordered = false;
         reliableBindingElement.ReliableMessagingVersion = System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11;
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetHttpOrdered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetHttpUnordered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetTcpOrdered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         reliableBindingElement.ReliableMessagingVersion = System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11;
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.TcpTransportBindingElement tcpBindingElement = new System.ServiceModel.Channels.TcpTransportBindingElement();
         tcpBindingElement.MaxBufferSize          = int.MaxValue;
         tcpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(tcpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetTcpUnordered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.ReliableSessionBindingElement reliableBindingElement = new System.ServiceModel.Channels.ReliableSessionBindingElement();
         reliableBindingElement.Ordered = false;
         reliableBindingElement.ReliableMessagingVersion = System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11;
         result.Elements.Add(reliableBindingElement);
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.TcpTransportBindingElement tcpBindingElement = new System.ServiceModel.Channels.TcpTransportBindingElement();
         tcpBindingElement.MaxBufferSize          = int.MaxValue;
         tcpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(tcpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetTcpOrdered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize           = int.MaxValue;
         result.ReaderQuotas            = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize  = int.MaxValue;
         result.Security.Mode           = System.ServiceModel.SecurityMode.None;
         result.ReliableSession.Enabled = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.NetTcpUnordered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize           = int.MaxValue;
         result.ReaderQuotas            = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize  = int.MaxValue;
         result.Security.Mode           = System.ServiceModel.SecurityMode.None;
         result.ReliableSession.Enabled = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.WSHttpOrdered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.WS2007HttpBinding result = new System.ServiceModel.WS2007HttpBinding();
         result.ReaderQuotas                      = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize            = int.MaxValue;
         result.AllowCookies                      = true;
         result.ReliableSession.Enabled           = true;
         result.ReliableSession.Ordered           = true;
         result.ReliableSession.InactivityTimeout = new System.TimeSpan(6000000000);
         result.Security.Mode                     = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.WSHttpUnordered_WSReliableMessaging11_IWcfReliableService))
     {
         System.ServiceModel.WS2007HttpBinding result = new System.ServiceModel.WS2007HttpBinding();
         result.ReaderQuotas                      = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize            = int.MaxValue;
         result.AllowCookies                      = true;
         result.ReliableSession.Enabled           = true;
         result.ReliableSession.Ordered           = false;
         result.ReliableSession.InactivityTimeout = new System.TimeSpan(6000000000);
         result.Security.Mode                     = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.WSHttpOrdered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
         result.ReaderQuotas                      = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize            = int.MaxValue;
         result.AllowCookies                      = true;
         result.ReliableSession.Enabled           = true;
         result.ReliableSession.Ordered           = true;
         result.ReliableSession.InactivityTimeout = new System.TimeSpan(6000000000);
         result.Security.Mode                     = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.WSHttpUnordered_WSReliableMessagingFebruary2005_IWcfReliableService))
     {
         System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding();
         result.ReaderQuotas                      = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize            = int.MaxValue;
         result.AllowCookies                      = true;
         result.ReliableSession.Enabled           = true;
         result.ReliableSession.Ordered           = true;
         result.ReliableSession.InactivityTimeout = new System.TimeSpan(6000000000);
         result.Security.Mode                     = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
 }
Exemplo n.º 20
0
        protected void btninterfload_Click(object sender, EventArgs e)
        {
            try
            {
                System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
                binding.MaxReceivedMessageSize = int.MaxValue;
                string comtype = ddlcompanyname.SelectedValue;
                string bustype = ddlbusinesstype.SelectedValue;
                if (!string.IsNullOrEmpty(comtype) && !string.IsNullOrEmpty(bustype) && comtype.Contains(";"))
                {
                    string[] comlist         = comtype.Split(';');
                    string   currentUserName = BaseWebPart.GetCurrentUserLoginId();
                    string   dtcolstr        = "目标客户公司代码,目标客户公司名称,目标客户说明,语义内容,业务代码,业务代码说明,业务翻译说明,目标客户代码,目标客户代码英文描述,目标客户代码中文描述,我方代码,我方代码英文描述,我方代码中文描述,生效时间,失效时间";
                    CBOSServices.CodSwicthTableServiceClient client = new CBOSServices.CodSwicthTableServiceClient();
                    CBOSServices.CodSwicthTable[]            result = client.getCodSwitchMessage2(comlist[1], bustype);
                    if (result != null && result.Length > 0)
                    {
                        codeMap.DelCodeMapByComIDAndBusID(comlist[1].Trim(), bustype.Trim());//插入前先删除
                        foreach (CBOSServices.CodSwicthTable re in result)
                        {
                            if (string.IsNullOrEmpty(re.CODE_CBOS))
                            {
                                continue;
                            }
                            DataTable dt         = new DataTable();
                            string[]  dtitlelist = dtcolstr.Split(',');
                            foreach (string str in dtitlelist)
                            {
                                dt.Columns.Add(str);
                            }
                            DataRow dr = dt.NewRow();
                            dr[0]  = comlist[1];
                            dr[1]  = comlist[0];
                            dr[2]  = "";
                            dr[3]  = "";
                            dr[4]  = re.SWITCH_TAB_NAME;
                            dr[5]  = "";
                            dr[6]  = "";
                            dr[7]  = re.CODE_CBOS;
                            dr[8]  = re.CODE_NAME_E_CBOS;
                            dr[9]  = re.CODE_NAME_C_CBOS;
                            dr[10] = re.CODE_SWITCH;
                            dr[11] = re.CODE_NAME_E_SWITCH;
                            dr[12] = re.CODE_NAME_C_SWITCH;
                            dr[13] = "";
                            dr[14] = "";
                            dt.Rows.Add(dr);
                            codeMap.InsertTableFromDataTable(dt, currentUserName);
                        }
                    }
                    BindCodeMap();
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceloadsuc", "InterfaceUploadSuccess();", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceloaderror", "layer.alert('公司名称与业务代码不能为空!',8);", true);
                }
            }
            catch (Exception ex)
            {
                BaseComponent.Error("代码映射接口导入: " + ex.Message + "--------" + ex.StackTrace);

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceload", "layer.alert('接口导入出现异常,请联系管理员!',8);", true);
            }
            //finally
            //{
            //    //ddlcompanyname.SelectedValue = "all";
            //    //ddlbusinesstype.SelectedValue = "all";
            //}
        }