Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [WebMethod]
- public string SendSMS_NEW(string ChannelID,string LinkID,string Data)
- {
- String retxmlData="";
- try
- {
- if (Data.IndexOf("news_id:") >= 0)
- {
- long news_id = Convert.ToInt64(Data.Substring(8));
- Data = get_news_from_db(news_id);
- }
- HttpWebRequest req = null;
- HttpWebResponse rsp = null;
- //http://sdpcontentapi.mobi-mind.net/Content.asmx/UploadNormalText?User=test&Password=test&LinkID=123&ChannelID=123&Data=test%20data
- string uri = "http://sdpcontentapi.mobi-mind.net/Content.asmx";
- string action = "http://sdpcontentapi.mobi-mind.net/Content.asmx?op=UploadNormalText";
- req = (HttpWebRequest)WebRequest.Create(uri);
- req.Headers.Add("SOAPAction", action);
- req.Method = "POST"; // Post method
- req.ContentType = "text/xml; charset=utf-8";
- //req.ContentLength = "";
- //req.Accept = "application/soap+xml, application/dime, multipart/related, text/*";
- //req.UserAgent = "Axis/1.4";
- StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8);
- writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
- writer.Write("<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>");
- writer.Write("<soapenv:Header/>");
- writer.Write("<soapenv:Body>");
- writer.Write("<UploadNormalText xmlns=\"http://tempuri.org/\">");
- writer.Write("<User>FF27A4D413DA4EFF8F2EC3AF7482229F</User>");
- writer.Write("<Password>7rzI42Ga</Password>");
- writer.Write("<LinkID>" + LinkID + "</LinkID>");
- writer.Write("<ChannelID>" + ChannelID + "</ChannelID>");
- writer.Write("<Data>" + Data + "</Data>");
- writer.Write(" </UploadNormalText>");
- writer.Write("</soapenv:Body>");
- writer.Write("</soapenv:Envelope>");
- writer.Close();
- rsp = (HttpWebResponse)req.GetResponse();
- System.IO.StreamReader reader = new System.IO.StreamReader(rsp.GetResponseStream());
- retxmlData = reader.ReadToEnd();
- //MessageBox.Show(retxmlData);
- if (req != null) req.GetRequestStream().Close();
- if (rsp != null) rsp.GetResponseStream().Close();
- }
- catch (System.Net.WebException ex)
- {
- String responseFromServer = ex.Message.ToString() + " ";
- if (ex.Response != null)
- {
- using (WebResponse response = ex.Response)
- {
- Stream data = response.GetResponseStream();
- using (StreamReader reader = new StreamReader(data))
- {
- responseFromServer += reader.ReadToEnd();
- }
- }
- }
- }
- return retxmlData;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement