public void HttpSMS(apiSendSms vSendSms, apiValidateLogin vlogin)
        {
            apiSendSms       apis = vSendSms;
            apiValidateLogin apiv = vlogin;

            String encoded = System.Web.HttpUtility.HtmlEncode(vSendSms.msg_content);
            Uri    smsUri  = new Uri("http://www.smsglobal.com/http-api.php?action=sendsms&user="******"&password="******"&from=" + vSendSms.sms_from + "&to=" + vSendSms.sms_to + "&text=" + encoded);


            /// Need to add proxy support when I have it working.
            try
            {
                WebClient wc = new WebClient();
                using (Stream s = wc.OpenRead(smsUri))
                {
                    using (StreamReader r = new StreamReader(s))
                    {
                        apis._responce = getResponse(r);
                    }
                }
            } catch (Exception e) { }
        }
        /// <summary>
        /// Request a login from the SMSGlobal Soap API, get a ticket in return and put it into apiSendSMS class.
        /// </summary>
        /// <param name="_vlogin">ApiValidateLogin object</param>
        /// <param name="_sendSMS">apiSendSMS object</param>
        ///
        public void requestLogin(apiValidateLogin _vlogin, apiSendSms _sendSMS)
        {
            this.apiv = _vlogin;
            apiSendSms apis = _sendSMS;

            string loginTicket = null;

            HttpWebRequest request = WebRequest.Create("http://www.smsglobal.com/mobileworks/soapserver.php") as HttpWebRequest;

            Windows_7_Dialogs.SecurityDialog a = new Windows_7_Dialogs.SecurityDialog();

            /// Get proxy information if needed.

            //if (!request.Proxy.IsBypassed(request.RequestUri))
            if (isProxyActive(request.RequestUri, request) == true)
            {
                a.Show("Proxy Authentication", "The server you are trying to access requires a username and password." + Environment.NewLine);
                _cred = new NetworkCredential(a.UserData.Username, a.UserData.Password);
                request.Proxy.Credentials = _cred;
            }

            /// Add the needed headers for the SOAP API.
            request.Method      = "POST";
            request.ContentType = "text/xml";
            request.Headers.Add("urn:MobileWorks#apiValidateLogin");

            ///Create an XML Document, with the needed data inside.
            var document = new XDocument(
                new XDeclaration("1.0", String.Empty, String.Empty),
                new XElement(soapenv + "Envelope", new XAttribute(XNamespace.Xmlns + "SOAP-ENV", soapenv),
                             new XElement(soapenv + "Body",
                                          new XElement("apiValidateLogin",
                                                       new XElement("user", apiv.APIusername),
                                                       new XElement("password", apiv.APIpassword)
                                                       ))));

            document.Declaration.Version = "1.0";
            ///As it doesn't seem to want to make the declaration, a work around is used. Creating a file, then appending the xml document made above, then loaded into the
            ///document object.
            //if (File.Exists(Environment.CurrentDirectory + @"\apiLogin.xml")) File.Delete(Environment.CurrentDirectory + @"\apiLogin.xml");
            //File.WriteAllText(Environment.CurrentDirectory + @"\apiLogin.xml", "<?xml version='1.0' ?>" + Environment.NewLine);
            //File.AppendAllText(Environment.CurrentDirectory + @"\apiLogin.xml", document.ToString());
            //document = XDocument.Load(Environment.CurrentDirectory + @"\apiLogin.xml");

            ///Write the document to the requested place, in this case is the Soap API at SMSGLobal.com
            var writer = new StreamWriter(request.GetRequestStream());

            writer.WriteLine(document);
            writer.Close();

            ///Get the responce from the webserver after writing to the API.
            using (var rsp = request.GetResponse())
            {
                request.GetRequestStream().Close();
                if (rsp != null)
                {
                    using (var answerReader =
                               new StreamReader(rsp.GetResponseStream()))
                    {
                        ///Get the ticket which the server sent back using Regex to get the letter/digit mix of 32 characters.
                        var   readString = answerReader.ReadToEnd();
                        Regex r          = new Regex(@"(.*)ticket&gt;(.*)&lt;/ticket(.*)");
                        if (r.IsMatch(readString.ToString()))
                        {
                            Regex reg = new Regex(@"[A-Za-z0-9]{32}");
                            loginTicket = reg.Match(r.Match(readString.ToString()).ToString()).ToString();
                        }
                    }
                }
            }
            apis.ticket = loginTicket;
        }