با سلام
دوست عزيز You-See خسته نباشيد
چندي قبل در خصوص مشكل ارتباط با وب سرويس شركت "سامانه پيام كوتاه پيشخوان" صحبت كرده بوديم. در اين پست شما گفتيد معلوم نيست چه چيزي نوشتن. من هنوز مشكلم رو نتونستم با اون شركت حل كنم. شما راه حلي نميتونين پيشنهاد كنيد؟
يه چنين يونيتي رو اضافه كردم ولي هيچ جوابي نميده. جديدا هرچي ميذارم ميگه كاربر مورد نظر وجود ندارد.
برنامه كامل همراه با يوزر و پسورد رو هم براتون پيام خصوصي كردم
// ************************************************** ********************** //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://ws.smspishkhan.ir/SmsService.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2013/11/04 12:56:02 È.Ù - 1.33.2.5)
// ************************************************** ********************** //
unit SmsService;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
// ************************************************** ********************** //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************** ********************** //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:decimal - "http://www.w3.org/2001/XMLSchema"
// !:short - "http://www.w3.org/2001/XMLSchema"
// !:float - "http://www.w3.org/2001/XMLSchema"
AccountCredentials = class; { "http://smspishkhan.ir/webservices/"[H] }
WsResponce = class; { "http://smspishkhan.ir/webservices/" }
WsMessageInfo = class; { "http://smspishkhan.ir/webservices/" }
WsSendResponce = class; { "http://smspishkhan.ir/webservices/" }
WsListOfStringResponce = class; { "http://smspishkhan.ir/webservices/" }
WsScheduleInfo = class; { "http://smspishkhan.ir/webservices/" }
WsRecieveMessage = class; { "http://smspishkhan.ir/webservices/" }
WsRecieveResponce = class; { "http://smspishkhan.ir/webservices/" }
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
AccountCredentials = class(TSOAPHeader)
private
Fusername: WideString;
Fpassword: WideString;
published
property username: WideString read Fusername write Fusername;
property password: WideString read Fpassword write Fpassword;
end;
ArrayOfDecimal = array of TXSDecimal; { "http://smspishkhan.ir/webservices/" }
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsResponce = class(TRemotable)
private
FErrorCode: Integer;
FErrorDesc: WideString;
published
property ErrorCode: Integer read FErrorCode write FErrorCode;
property ErrorDesc: WideString read FErrorDesc write FErrorDesc;
end;
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsMessageInfo = class(TRemotable)
private
FMessagesId: TXSDecimal;
FRecipient: WideString;
FPartsCount: Smallint;
FTariff: Single;
FAmount: TXSDecimal;
FStatus: Smallint;
FStatusTime: WideString;
FResponseDesc: WideString;
FUserMessageRef: WideString;
public
destructor Destroy; override;
published
property MessagesId: TXSDecimal read FMessagesId write FMessagesId;
property Recipient: WideString read FRecipient write FRecipient;
property PartsCount: Smallint read FPartsCount write FPartsCount;
property Tariff: Single read FTariff write FTariff;
property Amount: TXSDecimal read FAmount write FAmount;
property Status: Smallint read FStatus write FStatus;
property StatusTime: WideString read FStatusTime write FStatusTime;
property ResponseDesc: WideString read FResponseDesc write FResponseDesc;
property UserMessageRef: WideString read FUserMessageRef write FUserMessageRef;
end;
ArrayOfWsMessageInfo = array of WsMessageInfo; { "http://smspishkhan.ir/webservices/" }
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsSendResponce = class(WsResponce)
private
FRequestId: TXSDecimal;
FTotalCount: TXSDecimal;
FTotalParts: TXSDecimal;
FTotalAmount: TXSDecimal;
FIsPartitioned: Smallint;
FStatus: Smallint;
FStatusTime: WideString;
FMessages: ArrayOfWsMessageInfo;
FSubRequestsId: ArrayOfDecimal;
public
destructor Destroy; override;
published
property RequestId: TXSDecimal read FRequestId write FRequestId;
property TotalCount: TXSDecimal read FTotalCount write FTotalCount;
property TotalParts: TXSDecimal read FTotalParts write FTotalParts;
property TotalAmount: TXSDecimal read FTotalAmount write FTotalAmount;
property IsPartitioned: Smallint read FIsPartitioned write FIsPartitioned;
property Status: Smallint read FStatus write FStatus;
property StatusTime: WideString read FStatusTime write FStatusTime;
property Messages: ArrayOfWsMessageInfo read FMessages write FMessages;
property SubRequestsId: ArrayOfDecimal read FSubRequestsId write FSubRequestsId;
end;
ArrayOfString = array of WideString; { "http://smspishkhan.ir/webservices/" }
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsListOfStringResponce = class(WsResponce)
private
FLines: ArrayOfString;
published
property Lines: ArrayOfString read FLines write FLines;
end;
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsScheduleInfo = class(TRemotable)
private
FScheduleTime: WideString;
FIntervalPeriod: Integer;
FIntervalCount: Integer;
FDayStartTime: WideString;
FDayEndTime: WideString;
published
property ScheduleTime: WideString read FScheduleTime write FScheduleTime;
property IntervalPeriod: Integer read FIntervalPeriod write FIntervalPeriod;
property IntervalCount: Integer read FIntervalCount write FIntervalCount;
property DayStartTime: WideString read FDayStartTime write FDayStartTime;
property DayEndTime: WideString read FDayEndTime write FDayEndTime;
end;
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsRecieveMessage = class(TRemotable)
private
FId: TXSDecimal;
FLineNo: WideString;
FSenderNo: WideString;
FUDH: WideString;
FBody: WideString;
FEncoding: Smallint;
FTariff: Single;
FPartsCount: Smallint;
FAmount: TXSDecimal;
FRecieveTime: WideString;
public
destructor Destroy; override;
published
property Id: TXSDecimal read FId write FId;
property LineNo: WideString read FLineNo write FLineNo;
property SenderNo: WideString read FSenderNo write FSenderNo;
property UDH: WideString read FUDH write FUDH;
property Body: WideString read FBody write FBody;
property Encoding: Smallint read FEncoding write FEncoding;
property Tariff: Single read FTariff write FTariff;
property PartsCount: Smallint read FPartsCount write FPartsCount;
property Amount: TXSDecimal read FAmount write FAmount;
property RecieveTime: WideString read FRecieveTime write FRecieveTime;
end;
ArrayOfWsRecieveMessage = array of WsRecieveMessage; { "http://smspishkhan.ir/webservices/" }
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// ************************************************** ********************** //
WsRecieveResponce = class(WsResponce)
private
FRecieveMessages: ArrayOfWsRecieveMessage;
public
destructor Destroy; override;
published
property RecieveMessages: ArrayOfWsRecieveMessage read FRecieveMessages write FRecieveMessages;
end;
// ************************************************** ********************** //
// Namespace : http://smspishkhan.ir/webservices/
// soapAction: http://smspishkhan.ir/webservices/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : SmsServiceSoap
// service : SmsService
// port : SmsServiceSoap
// URL : http://ws.smspishkhan.ir/SmsService.asmx
// ************************************************** ********************** //
SmsServiceSoap = interface(IInvokable)
['{18256B71-4CBE-04CC-E231-F277B843141D}']
function SendMessage(const lineNo: WideString; const body: WideString; const recipient: WideString; const messageClass: Integer; const scheduleTime: WideString): WsSendResponce; stdcall;
function SendGroupMessage(const lineNo: WideString; const body: WideString; const recipients: ArrayOfString; const messageClass: Integer; const scheduleInfo: WsScheduleInfo): WsSendResponce; stdcall;
function GetUserLines: WsListOfStringResponce; stdcall;
function RecieveMessages(const lineNo: WideString; const timeFrom: WideString; const messageCount: Integer): WsRecieveResponce; stdcall;
function GetRequestStatus(const requestId: TXSDecimal): WsSendResponce; stdcall;
end;
function GetSmsServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): SmsServiceSoap;
implementation
procedure HTTPRIO1BeforeExecute(const MethodName: String;
var SOAPRequest: WideString);
begin
SOAPRequest :=
'<?xml version="1.0" encoding="utf-8"?>' +
'<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/">'+
// '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
'<soap:Header>' +
'<AccountCredentials xmlns="http://smspishkhan.ir/webservices/">' +
'<username>user</username>' +
'<password>pass</password>' +
'</AccountCredentials>' +
'</soap:Header>' +
'<soap:Body>' +
'<SendMessage xmlns="http://smspishkhan.ir/webservices/">' +
'<lineNo>10000333000000<lineNo>' +
'<body>test</body>' +
'<recipient>9115152509</recipient>' +
'<messageClass>0</messageClass>' +
'</SendMessage>' +
'</soap:Body>' +
'</soap:Envelope>' ;
end;
function GetSmsServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): SmsServiceSoap;
const
defWSDL = 'http://ws.smspishkhan.ir/SmsService.asmx?wsdl';
defURL = 'http://ws.smspishkhan.ir/SmsService.asmx';
defSvc = 'SmsService';
defPrt = 'SmsServiceSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as SmsServiceSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
destructor WsMessageInfo.Destroy;
begin
if Assigned(FMessagesId) then
FMessagesId.Free;
if Assigned(FAmount) then
FAmount.Free;
inherited Destroy;
end;
destructor WsSendResponce.Destroy;
var
I: Integer;
begin
for I := 0 to Length(FMessages)-1 do
if Assigned(FMessages[I]) then
FMessages[I].Free;
SetLength(FMessages, 0);
for I := 0 to Length(FSubRequestsId)-1 do
if Assigned(FSubRequestsId[I]) then
FSubRequestsId[I].Free;
SetLength(FSubRequestsId, 0);
if Assigned(FRequestId) then
FRequestId.Free;
if Assigned(FTotalCount) then
FTotalCount.Free;
if Assigned(FTotalParts) then
FTotalParts.Free;
if Assigned(FTotalAmount) then
FTotalAmount.Free;
inherited Destroy;
end;
destructor WsRecieveMessage.Destroy;
begin
if Assigned(FId) then
FId.Free;
if Assigned(FAmount) then
FAmount.Free;
inherited Destroy;
end;
destructor WsRecieveResponce.Destroy;
var
I: Integer;
begin
for I := 0 to Length(FRecieveMessages)-1 do
if Assigned(FRecieveMessages[I]) then
FRecieveMessages[I].Free;
SetLength(FRecieveMessages, 0);
inherited Destroy;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(SmsServiceS oap), 'http://smspishkhan.ir/webservices/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Sms ServiceSoap), 'http://smspishkhan.ir/webservices/%operationName%');
InvRegistry.RegisterHeaderClass(TypeInfo(SmsServic eSoap), AccountCredentials, 'AccountCredentials', '');
RemClassRegistry.RegisterXSClass(AccountCredential s, 'http://smspishkhan.ir/webservices/', 'AccountCredentials');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfDe cimal), 'http://smspishkhan.ir/webservices/', 'ArrayOfDecimal');
RemClassRegistry.RegisterXSClass(WsResponce, 'http://smspishkhan.ir/webservices/', 'WsResponce');
RemClassRegistry.RegisterXSClass(WsMessageInfo, 'http://smspishkhan.ir/webservices/', 'WsMessageInfo');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfWs MessageInfo), 'http://smspishkhan.ir/webservices/', 'ArrayOfWsMessageInfo');
RemClassRegistry.RegisterXSClass(WsSendResponce, 'http://smspishkhan.ir/webservices/', 'WsSendResponce');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfSt ring), 'http://smspishkhan.ir/webservices/', 'ArrayOfString');
RemClassRegistry.RegisterXSClass(WsListOfStringRes ponce, 'http://smspishkhan.ir/webservices/', 'WsListOfStringResponce');
RemClassRegistry.RegisterXSClass(WsScheduleInfo, 'http://smspishkhan.ir/webservices/', 'WsScheduleInfo');
RemClassRegistry.RegisterXSClass(WsRecieveMessage, 'http://smspishkhan.ir/webservices/', 'WsRecieveMessage');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfWs RecieveMessage), 'http://smspishkhan.ir/webservices/', 'ArrayOfWsRecieveMessage');
RemClassRegistry.RegisterXSClass(WsRecieveResponce , 'http://smspishkhan.ir/webservices/', 'WsRecieveResponce'); //'http://smspishkhan.ir/webservices'
end.