public
static
int
StaticSendSMS(
string
Sender,
string
Receiver,
string
Message)
{
Message = Message.Replace( " & " , " & " );
Message = Message.Replace( " < " , " < " );
Message = Message.Replace( " > " , " > " );
Message = Message.Replace( " /" " , " " " );
Message = Message.Replace( " ' " , " ' " );
Encoding encode = System.Text.Encoding.GetEncoding( " utf-8 " );
string XmlStr = " <?xml version=/"1.0/" encoding=/"utf-8/"?>/n " +
" <SOAP-ENV:Envelope xmlns:SOAP-ENV=/"http://schemas.xmlsoap.org/soap/envelope//" xmlns:SOAP-ENC=/"http://schemas.xmlsoap.org/soap/encoding//" xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/" xmlns:m0=/"http://etos.eastelsoft.com/v1/">/n " +
" <SOAP-ENV:Body>/n " +
" <m:sendSms xmlns:m=/"http://www.openuri.org//">/n " +
" <m:request>/n " +
" <m0:Sender> " + Sender + " </m0:Sender>/n " +
" <m0:Receiver> " + Receiver + " </m0:Receiver>/n " +
" <m0:Message> " + Message + " </m0:Message>/n " +
" </m:request>/n " +
" </m:sendSms>/n " +
" </SOAP-ENV:Body>/n " +
" </SOAP-ENV:Envelope>/n/n " ;
byte [] postByte = encode.GetBytes(XmlStr);
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create( " http://220.250.64.142/etos2test/services/ETOS2SMS " );
myHttpWebRequest.Method = " POST " ;
myHttpWebRequest.ContentType = " application/xop+xml; charset=utf-8; type=/"text/xml " ;
myHttpWebRequest.ContentLength = postByte.Length;
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(postByte, 0 , postByte.Length);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, encode);
Char[] read = new Char[ 256 ];
String ResponseText = "" ;
int count = readStream.Read(read, 0 , read.Length);
while (count > 0 )
{
ResponseText += new String(read, 0 , count);
count = readStream.Read(read, 0 , read.Length);
}
readStream.Close();
receiveStream.Close();
myHttpWebResponse.Close();
string RS = " <Result xmlns=/"http://etos.eastelsoft.com/v1/"> " ;
string RE = " </Result> " ;
int RSi = ResponseText.ToLower().IndexOf(RS.ToLower());
int REi = ResponseText.ToLower().IndexOf(RE.ToLower());
string Result = " -2 " ;
if (RSi > 0 )
Result = ResponseText.Substring(RSi + RS.Length, REi - RSi - RS.Length);
return int .Parse(Result);
}
{
Message = Message.Replace( " & " , " & " );
Message = Message.Replace( " < " , " < " );
Message = Message.Replace( " > " , " > " );
Message = Message.Replace( " /" " , " " " );
Message = Message.Replace( " ' " , " ' " );
Encoding encode = System.Text.Encoding.GetEncoding( " utf-8 " );
string XmlStr = " <?xml version=/"1.0/" encoding=/"utf-8/"?>/n " +
" <SOAP-ENV:Envelope xmlns:SOAP-ENV=/"http://schemas.xmlsoap.org/soap/envelope//" xmlns:SOAP-ENC=/"http://schemas.xmlsoap.org/soap/encoding//" xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/" xmlns:m0=/"http://etos.eastelsoft.com/v1/">/n " +
" <SOAP-ENV:Body>/n " +
" <m:sendSms xmlns:m=/"http://www.openuri.org//">/n " +
" <m:request>/n " +
" <m0:Sender> " + Sender + " </m0:Sender>/n " +
" <m0:Receiver> " + Receiver + " </m0:Receiver>/n " +
" <m0:Message> " + Message + " </m0:Message>/n " +
" </m:request>/n " +
" </m:sendSms>/n " +
" </SOAP-ENV:Body>/n " +
" </SOAP-ENV:Envelope>/n/n " ;
byte [] postByte = encode.GetBytes(XmlStr);
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create( " http://220.250.64.142/etos2test/services/ETOS2SMS " );
myHttpWebRequest.Method = " POST " ;
myHttpWebRequest.ContentType = " application/xop+xml; charset=utf-8; type=/"text/xml " ;
myHttpWebRequest.ContentLength = postByte.Length;
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(postByte, 0 , postByte.Length);
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, encode);
Char[] read = new Char[ 256 ];
String ResponseText = "" ;
int count = readStream.Read(read, 0 , read.Length);
while (count > 0 )
{
ResponseText += new String(read, 0 , count);
count = readStream.Read(read, 0 , read.Length);
}
readStream.Close();
receiveStream.Close();
myHttpWebResponse.Close();
string RS = " <Result xmlns=/"http://etos.eastelsoft.com/v1/"> " ;
string RE = " </Result> " ;
int RSi = ResponseText.ToLower().IndexOf(RS.ToLower());
int REi = ResponseText.ToLower().IndexOf(RE.ToLower());
string Result = " -2 " ;
if (RSi > 0 )
Result = ResponseText.Substring(RSi + RS.Length, REi - RSi - RS.Length);
return int .Parse(Result);
}