Class to handle HTTPS and non HTTP services

To follow the post from yesterday I created a class to handle better HTTPS and HTTP web services. The problem is not seeing the request in HTTPS, just the connection to the server.

 

public class SSLSilverlightWebServiceProxy : SSLService.SimpleSilverlightWebServiceSoapClient
    {
        public SSLSilverlightWebServiceProxy()            
        {
            if (Config.Globals.WebService.Address != null)
            {
                if (Config.Globals.WebService.Address.Length > 0)
                {
                    Config.Globals.WebService.Address = Config.Globals.WebService.Address.ToLower().Replace("silverlightwebservice.svc", "SimpleSilverlightWebService.asmx");
                    System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(Config.Globals.WebService.Address);
                    base.Endpoint.Address = address;

                     //HTTPS                    
                    if (address.Uri.ToString().ToLower().IndexOf("https") == 0)
                    {
                        if (base.Endpoint.Contract.Name.IndexOf("SSL") == -1)
                        {
                            System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.Transport);
                            base.Endpoint.Contract.Name = base.Endpoint.Contract.Name + "SSL";

                            myBinding.MaxReceivedMessageSize = 2147483647;
                            myBinding.MaxBufferSize = 2147483647;
                            base.Endpoint.Binding = myBinding;
                        }
                    }
                    else
                    {
                        System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.None);
                        base.Endpoint.Contract.Name = base.Endpoint.Contract.Name;

                        myBinding.MaxReceivedMessageSize = 2147483647;
                        myBinding.MaxBufferSize = 2147483647;
                        base.Endpoint.Binding = myBinding;
                    }
                }
            }   
        }

#1 Matt Watson on 6.17.2009 at 8:28 PM

Here is something similar that does even more and is more flexible

geekswithblogs.net/.../129655.aspx