Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I m working on website which is an SMS application i.e. user can send sms using this site.
The sms is sent properly sometimes and sometimes not
all the functions work fine except the following which gets ValueFirstResponse using ASCII encoding.
when any sms is sent successfully, ValueFirstResponse using ASCII encoding is as follows (for example)

<messageack><guid guid="kb8gd185534651f461014i8ib8DEMOVFWSTX" submitdate="2011-08-16 13:18:55" id="634490975444658044"><error seq="1" code="28681">

XML
<messageack><guid guid="kb8gd062289051f461014pgq48DEMOVFWSTX" submitdate="2011-08-16 13:06:22" id="634490967933047470"><b><big><error seq="1" code="28681" /></big></b></guid></messageack

>




when this <error seq="1" code="28681"> comes that means error occured im not getting why this is occuring. The complete function is
C#
public string SendHighPriorityXMLtoValueFirst(long dateTicks, long targetNo, string msgType, string msgHdr, string msgDtls, string from)
        {
            try
            {
                WebProxy _webProxy = null;

                StringBuilder XMLforVauleFirstAPI = new StringBuilder();
                XMLforVauleFirstAPI.Append("");
                XMLforVauleFirstAPI.Append("<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1/psms/dtd/messagev12.dtd\" >");
                XMLforVauleFirstAPI.Append("<message ver="\">");
                XMLforVauleFirstAPI.Append("<user username="\" mode="hold" />                XMLforVauleFirstAPI.Append(HPUserName);
                XMLforVauleFirstAPI.Append("\" PASSWORD=\"");
                XMLforVauleFirstAPI.Append(HPPassword);
                XMLforVauleFirstAPI.Append("\"/>");
                WriteSMSLog("SendHighPriorityXMLtoValueFirst|" + dateTicks + "|" + targetNo + "|" + msgType + "|" + msgHdr + "|" + msgDtls + "|" + from);

                try
                {
                    //SendXMLtoValueFirst(From, TargetNo, MsgDtls);
                    XMLforVauleFirstAPI.Append("<sms udh="\" coding="\" text="\" mode="hold" />                    XMLforVauleFirstAPI.Append(msgDtls);
                    XMLforVauleFirstAPI.Append("\" PROPERTY=\"0\" ID=\"");
                    XMLforVauleFirstAPI.Append(dateTicks);
                    XMLforVauleFirstAPI.Append("\">");
                    XMLforVauleFirstAPI.Append("<address from="\" mode="hold" />                    XMLforVauleFirstAPI.Append(from);
                    XMLforVauleFirstAPI.Append("\" TO=\"");
                    XMLforVauleFirstAPI.Append(targetNo);
                    XMLforVauleFirstAPI.Append("\" SEQ=");
                    XMLforVauleFirstAPI.Append("\"");
                    XMLforVauleFirstAPI.Append(1);
                    XMLforVauleFirstAPI.Append("\" TAG=\"NCDEX\" />");
                    XMLforVauleFirstAPI.Append("");
                }
                catch (Exception ex)
                {
                    WriteSMSLog("SendHighPriorityXMLtoValueFirst|Ex-->" + ex.Message);
                }

                XMLforVauleFirstAPI.Append("</message>");
                string strXML = XMLforVauleFirstAPI.ToString();

                string xmlparameter = System.Uri.EscapeUriString(strXML);
                string URL = Server.UrlPathEncode(ValueFirstAPIPath + xmlparameter + "&action=send");

                mVFRequestSentTime = System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");

                string throughProxy = ConfigurationSettings.AppSettings["ThroughProxy"].ToString();
                if (throughProxy == "Y")
                {
                    string ProxyIP = ConfigurationSettings.AppSettings["ProxyIP"].ToString();
                    int ProxyPort = Convert.ToInt32(ConfigurationSettings.AppSettings["ProxyPort"]);
                    string McUserName = ConfigurationSettings.AppSettings["NwUserName"].ToString();
                    string McPassword = ConfigurationSettings.AppSettings["NwPassword"].ToString();
                    string McDomain = ConfigurationSettings.AppSettings["NwDomain"].ToString();

                    _webProxy = new WebProxy(ProxyIP, ProxyPort);
                    NetworkCredential _networkCredential = new NetworkCredential(McUserName, McPassword, McDomain);
                    _webProxy.Credentials = _networkCredential;
                }

                Uri objUri = new Uri(URL);
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(objUri);
                if (throughProxy == "Y")
                {
                    objRequest.Proxy = _webProxy;
                }
                WriteSMSLog("SendXMLtoValueFirst-->" + URL);

                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                Stream objStrm = objResponse.GetResponseStream();

                byte[] buffer = new byte[500000];
                objStrm.Read(buffer, 0, 500000);

                ASCIIEncoding objEncoder = new ASCIIEncoding();
           <big>valueFirstResponse = objEncoder.GetString(buffer);</big>

                mVFResponseRcvdTime = System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
                return valueFirstResponse;

            }
            catch (Exception ex)
            {
                WriteSMSLog("SendHighPriorityXMLtoValueFirst|Ex-->" + ex.Message);
                return "Exception Occured.";
            }

        }
Posted
Updated 26-Aug-11 0:32am
v4
Comments
BobJanova 16-Aug-11 5:49am    
You are getting a successful response to the web service call (i.e. no exception), but the content of that response indicated that the server rejected your SMS? You need to ask about this on the forum of your SMS service provider.
Member 8081020 16-Aug-11 5:52am    
will u please elaborate?
Tech Code Freak 26-Aug-11 6:39am    
Who is your SMS service provider?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900