Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1.  
  2. [WebMethod]
  3. public string SendSMS_NEW(string ChannelID,string LinkID,string Data)
  4. {
  5. String retxmlData="";
  6. try
  7. {
  8. if (Data.IndexOf("news_id:") >= 0)
  9. {
  10. long news_id = Convert.ToInt64(Data.Substring(8));
  11. Data = get_news_from_db(news_id);
  12. }
  13.  
  14. HttpWebRequest req = null;
  15. HttpWebResponse rsp = null;
  16.  
  17. //http://sdpcontentapi.mobi-mind.net/Content.asmx/UploadNormalText?User=test&Password=test&LinkID=123&ChannelID=123&Data=test%20data
  18.  
  19. string uri = "http://sdpcontentapi.mobi-mind.net/Content.asmx";
  20. string action = "http://sdpcontentapi.mobi-mind.net/Content.asmx?op=UploadNormalText";
  21. req = (HttpWebRequest)WebRequest.Create(uri);
  22. req.Headers.Add("SOAPAction", action);
  23. req.Method = "POST"; // Post method
  24. req.ContentType = "text/xml; charset=utf-8";
  25. //req.ContentLength = "";
  26.  
  27. //req.Accept = "application/soap+xml, application/dime, multipart/related, text/*";
  28. //req.UserAgent = "Axis/1.4";
  29.  
  30. StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8);
  31. writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
  32. writer.Write("<soap: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/'>");
  33. writer.Write("<soap:Body>");
  34. writer.Write("<UploadNormalText xmlns=\"http://tempuri.org/\">");
  35. writer.Write("<User>FF27A4D413DA4EFF8F2EC3AF7482229F</User>");
  36. writer.Write("<Password>7rzI42Ga</Password>");
  37. writer.Write("<LinkID>" + LinkID + "</LinkID>");
  38. writer.Write("<ChannelID>" + ChannelID + "</ChannelID>");
  39. writer.Write("<Data>" + Data + "</Data>");
  40. writer.Write(" </UploadNormalText>");
  41. writer.Write("</soap:Body>");
  42. writer.Write("</soap:Envelope>");
  43.  
  44. writer.Close();
  45.  
  46. rsp = (HttpWebResponse)req.GetResponse();
  47.  
  48. System.IO.StreamReader reader = new System.IO.StreamReader(rsp.GetResponseStream());
  49. retxmlData = reader.ReadToEnd();
  50. //MessageBox.Show(retxmlData);
  51. if (req != null) req.GetRequestStream().Close();
  52. if (rsp != null) rsp.GetResponseStream().Close();
  53.  
  54. }
  55. catch (System.Net.WebException ex)
  56. {
  57. String responseFromServer = ex.Message.ToString() + " ";
  58. if (ex.Response != null)
  59. {
  60. using (WebResponse response = ex.Response)
  61. {
  62. Stream data = response.GetResponseStream();
  63. using (StreamReader reader = new StreamReader(data))
  64. {
  65. responseFromServer += reader.ReadToEnd();
  66. }
  67. }
  68. }
  69.  
  70. }
  71. return retxmlData;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement