Delphi短信介面開發可以利用delphi的SOAPHTTPClient、HTTPRIO等來實作短信的提交,下面的代碼摘自速達移動(sudas.cn)提供的樣例程式,僅摘取Unit1.pas檔案原始碼和Unit2.pas檔案原始碼。
Unit1.pas檔案原始碼:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Unit2;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text:=Unit2.GetMyWebServericeSoap(false,'http://sdk.sudas.cn/submitdata/service.asmx').g_Submit('','','','802','13426107503','test');
end;
end.
Unit2.pas檔案原始碼:
unit Unit2;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
MyWebServericeSoap = interface(IInvokable)
['{5BA22C24-B55B-44D5-63A4-623BCC4101FC}']
function g_Submit(const sname: WideString; const spwd: WideString; const scorpid: WideString; const sprdid: WideString; const sdst: WideString; const smsg: WideString): WideString; stdcall;
end;
function GetMyWebServericeSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): MyWebServericeSoap;
implementation
function GetMyWebServericeSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): MyWebServericeSoap;
const
defWSDL = 'http://sdk.sudas.cn/submitdata/service.asmx?wsdl';
defURL = 'http://sdk.sudas.cn/submitdata/service.asmx';
defSvc = 'Unit2';
defPrt = 'MyWebServericeSoap';
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 MyWebServericeSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
//
RIO.HTTPWebNode.UseUTF8InHeader:=True;
//
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(MyWebServericeSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(MyWebServericeSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(MyWebServericeSoap), ioDocument);
end.
代碼中的g_Submit函式,第一個引數填用戶名,第二個引數是密碼,第三個置空。第4個引數是產品代碼,第5個要發送的的手機號碼,第6個是資訊內容
Unit2.GetMyWebServericeSoap(false,'http://sdk.sudas.cn/submitdata/service.asmx').g_Submit('','','','802','13426107503','test');
以上是參考速達移動的短信提交介面,具體提交的地址與需要填寫的內容請聯系您的服務商。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/80224.html
標籤:語言基礎/算法/系統設計
上一篇:Delphi+Sql 2005 +FastReport 多行備注排版對齊問題?
下一篇:Delphi代碼轉換成C#怎么寫
