예제 #1
0
        /// <summary>
        /// Loads the binding's settings from a XML encoded string.
        /// </summary>
        /// <param name="binding">The binding.</param>
        /// <param name="settings">The settings.</param>
        /// <exception cref="ArgumentException">Thrown if the settings are not valid.</exception>
        private void LoadSettings(System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding binding, string settings)
        {
            if (string.IsNullOrWhiteSpace(settings))
            {
                return;
            }

            throw new NotImplementedException();    // $todo(jeff.lill): Implement this
        }
예제 #2
0
        internal static Binding CreateBinding(string flag)
        {
            Binding binding = null;

            switch (flag)
            {
            case "NetTcp":
                binding = new NetTcpBinding();
                break;

            case "BasicHttp":
                binding = new BasicHttpBinding();
                break;

            case "WSHttp":
                binding = new WSHttpBinding();
                break;

            case "WSDualHttp":
                binding = new WSDualHttpBinding();
                break;

            case "WSFederationHttp":
                binding = new WSFederationHttpBinding();
                break;

            case "NetNamedPipe":
                binding = new NetNamedPipeBinding();
                break;

            case "NetMsmq":
                binding = new NetMsmqBinding();
                break;

            case "NetPeerTcp":
                binding = new NetPeerTcpBinding();
                break;

            case "MsmqIntegration":
                binding = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                break;

            default:
                binding = new NetTcpBinding();
                break;
            }

            return(binding);
        }
예제 #3
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;
        }
예제 #4
0
        private ArgCollection args; // The endpoint arguments

        /// <summary>
        /// Parses a <see cref="WcfEndpoint" /> from a string formatted as a standard
        /// <see cref="ArgCollection" />.
        /// </summary>
        /// <param name="input">The input string.</param>
        public WcfEndpoint(string input)
        {
            string bindingName;
            string arg;
            int    cbMsgMax;
            int    cbBuffer;
            string settings;

            args = ArgCollection.Parse(input);

            // Get the endpoint address URI

            arg = args.Get("uri");
            if (arg == null)
            {
                throw new ArgumentException("[Uri] argument is required.");
            }

            try
            {
                uri = new Uri(arg);
            }
            catch
            {
                throw new ArgumentException(string.Format("Invalid [Uri={0}].", arg));
            }

            // Initialize the binding

            arg = args.Get("binding");
            if (arg == null)
            {
                throw new ArgumentException("[Binding] argument is required.");
            }

            cbMsgMax = args.Get("MaxMessageSize", 64 * 1024);
            cbBuffer = Math.Min(64 * 1024, cbMsgMax);

            settings = args.Get("Settings");

            bindingName = arg.ToUpper();
            switch (bindingName)
            {
            case "LILLTEK":

                LillTekBinding lilltekBinding;

                binding = lilltekBinding = new LillTekBinding(uri);

                // $todo(jeff.lill): The LillTek transport needs to implement settings.

                break;

            case "BASICHTTP":

                BasicHttpBinding basicBinding;

                binding = basicBinding = new BasicHttpBinding();
                basicBinding.MaxBufferSize          = cbBuffer;
                basicBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(basicBinding, settings);
                break;

            case "HTTP":

                WSHttpBinding wsHttpBinding;

                binding = wsHttpBinding = new WSHttpBinding();
                wsHttpBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(wsHttpBinding, settings);
                break;

            case "DUALHTTP":

                WSDualHttpBinding wsDualHttpBinding;

                binding = wsDualHttpBinding = new WSDualHttpBinding();
                wsDualHttpBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(wsDualHttpBinding, settings);
                break;

            case "FEDERATIONHTTP":

                WSFederationHttpBinding wsFederationHttpBinding;

                binding = wsFederationHttpBinding = new WSFederationHttpBinding();
                wsFederationHttpBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(wsFederationHttpBinding, settings);
                break;

            case "TCP":

                NetTcpBinding netTcpBinding;

                binding = netTcpBinding = new NetTcpBinding();
                netTcpBinding.MaxBufferSize          = cbBuffer;
                netTcpBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(netTcpBinding, settings);
                break;

            case "NAMEDPIPE":

                NetNamedPipeBinding netPipeBinding;

                binding = netPipeBinding = new NetNamedPipeBinding();
                netPipeBinding.MaxBufferSize          = cbBuffer;
                netPipeBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(netPipeBinding, settings);
                break;

            case "MSMQ":

                NetMsmqBinding netMsmqBinding;

                binding = netMsmqBinding = new NetMsmqBinding();
                netMsmqBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(netMsmqBinding, settings);
                break;

            case "PEERTCP":

                NetPeerTcpBinding netPeerTcpBinding;

                binding = netPeerTcpBinding = new NetPeerTcpBinding();
                netPeerTcpBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(netPeerTcpBinding, settings);
                break;

            case "MSMQINTEGRATION":

                System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding msmqIntegrationBinding;

                binding = msmqIntegrationBinding = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                msmqIntegrationBinding.MaxReceivedMessageSize = cbMsgMax;

                LoadSettings(msmqIntegrationBinding, settings);
                break;

            default:

                throw new ArgumentException(string.Format("Unsupported WcfEndpoint binding type [Binding={0}].", arg));
            }
        }
예제 #5
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);
        }