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">
<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
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
{
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.";
}
}