Const XMLHeader='<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body>';
//XMLFoolter='</SendSimpleSMS></soap12:Body></soap12:Envelope>';
XMLFoolter='</SOAP-ENV:Body></SOAP-ENV:Envelope>';
SendWebService='http://87.107.121.54/post/Send.asmx';
ActionWebService='http://www.payamak-panel.com/post/Actions.asmx';
ErrorComunication='خطا در ارتباط با سرویس' ;
function SendSms(useame,password:string;to_: ArrayOfString;from,text: string;isflash: Boolean;udh: string;var recId: ArrayOfLong; var status: TByteDynArray): Integer;
var
msg: WideString;
response: TStringStream;
request:TStringStream;
i:Smallint;
XML,flash:WideString;
len:integer;
begin
if isflash then
flash:='true'
else
flash:='false';
len:=length(to_);
msg := UTF8Encode(text);
XML:=XMLHeader+
'<SendSms xmlns="http://tempuri.org/">' +
'<useame>'+useame+'</useame>' +
'<password>'+password+'</password>' +
'<to>' ;
for i:=1 to Len do
XML:=XML+'<string>'+to_[i-1]+'</string>';
XML:=XML+'</to>' +
'<from>'+from+'</from>' +
'<text>'+msg+'</text>' +
'<isflash>'+flash+'</isflash>' +
'<udh>'+udh+'</udh>' +
'<recId/>' +
'<status xmlns="" xsi:nil="true"/>' +
'</SendSms>' +
XMLFoolter;
request := TStringStream.Create(XML);
SendSmsOne.IdHTTP1.Request.CustomHeaders.Text := 'SOAPAction: "http://tempuri.org/SendSms"';
SendSmsOne.IdHTTP1.Request.ContentType := 'text/xml; charset=utf-8';
response := TStringStream.Create('');
try
SendSmsOne.IdHTTP1.Post(SendWebService, request, response);
SendSmsOne.XMLDocument1.LoadFromStream(response);
SetLength(recId,Len);
SetLength(status,Len);
Result:=StrToIntDef(SendSmsOne.XMLDocument1.DOMDoc ument.getElementsByTagName('soap:Body').item[0].childNodes[0].childNodes[0].childNodes[0].nodeValue,-1);
//result:=1;
if Result=1 then
begin
for i:=1 to Len do
recId[i-1] :=StrToInt64Def(SendSmsOne.XMLDocument1.DOMDocumen t.getElementsByTagName('soap:Body').item[0].childNodes[0].childNodes[1].childNodes[i-1].childNodes[0].nodeValue,-1);
//for i:=1 to Len do
// status[i-1]:=StrToIntDef(Form1.XMLDocument1.DOMDocument.getEl ementsByTagName('soap:Body').item[0].childNodes[0].childNodes[2].childNodes[0].nodeValue,1)
status:=ConvertStatusStrToByteArr(SendSmsOne.XMLDo cument1.DOMDocument.getElementsByTagName('soap:Bod y').item[0].childNodes[0].childNodes[2].childNodes[0].nodeValue,len);
end
except
ShowMessage(ErrorComunication);
end;
end;
این هم نمونه کدی که استفاده کردم .
اگر نمونه کدی هم دارید ممنون میشم بزارین.
برچسب:
نویسنده: محمد رضا جوادیان