
服務端代碼:unit ws_chkhjIntf;
interface
uses InvokeRegistry, Types, XSBuiltIns,unyrecord;
type
{ Invokable interfaces must derive from IInvokable }
Iws_chkhj = interface(IInvokable)
['{00EB914C-CAC8-41E5-A38E-7A6AD7165AAC}']
{ Methods of Invokable interface must not use the default }
{ calling convention; stdcall is recommended }
//function getchkny():TStringDynArray;stdcall;
//function getny():TStringDynArray;stdcall;
function getny():tnyrecords;stdcall;
end;
implementation
initialization
{ Invokable interfaces must be registered }
InvRegistry.RegisterInterface(TypeInfo(Iws_chkhj));
end.
unit ws_chkhjImpl;
interface
uses InvokeRegistry, Types, XSBuiltIns, ws_chkhjIntf,Unit6,smod,unyrecord;
type
{ Tws_chkhj }
Tws_chkhj = class(TInvokableClass, Iws_chkhj)
public
//function getchkny():TStringDynArray;stdcall;
//function getny():TStringDynArray;stdcall;
function getny():tnyrecords;stdcall;
end;
implementation
//function Tws_chkhj.getny:TStringDynArray;stdcall;
function Tws_chkhj.getny():tnyrecords;stdcall;
var icount, ino:Integer;
ws_smod:Tws_smod;
begin
ino:=-1;
ws_smod:=Tws_smod.Create(nil);
//ws_smod.ADODataSet1.Active:=True;
//ws_smod.ADODataSet1.ClearFields;
ws_smod.ADODataSet1.CommandText:='select distinct ny from chk_ha1 order by ny desc';
ws_smod.ADODataSet1.Prepared;
ws_smod.ADODataSet1.Open;
icount:=ws_smod.ADODataSet1.RecordCount;
SetLength(Result,icount);
while not ws_smod.ADODataSet1.Eof do
begin
Inc(ino);
Result[ino].ny:=ws_smod.ADODataSet1.FieldByName('ny').Value;
//Result[ino]:=ws_smod.ADODataSet1.FieldByName('ny').Value;
ws_smod.ADODataSet1.Next;
end;
ws_smod.ADODataSet1.Active:=False;
end;
initialization
{ Invokable classes must be registered }
InvRegistry.RegisterInvokableClass(Tws_chkhj);
end.
unit unyrecord;
interface
uses
InvokeRegistry,XSBuiltIns;
type
Tnyrecord=class(TRemotable)
private
fny:string;
published
property ny:string read fny write fny;
end;
tnyrecords=array of Tnyrecord;
implementation
initialization
remclassregistry.RegisterXSClass(tnyrecord,'http://www.w3.org/2001/xmlschema','tnyrecord','',false);
remtyperegistry.RegisterXSInfo(TypeInfo(tnyrecords),'http://www.w3.org/2001/xmlschema','tnyrecords');
finalization
remclassregistry.UnRegisterXSClass(tnyrecord);
remtyperegistry.UnRegisterXSInfo(TypeInfo(tnyrecords));
end.
nit Unit6;
interface
uses
SysUtils, Classes, HTTPApp, InvokeRegistry, WSDLIntf, TypInfo, WebServExp,
WSDLBind, XMLSchema, WSDLPub, SOAPPasInv, SOAPHTTPPasInv, SOAPHTTPDisp,
WebBrokerSOAP, DBClient, Provider, DB, ADODB;
type
TWebModule6 = class(TWebModule)
HTTPSoapDispatcher1: THTTPSoapDispatcher;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
WSDLHTMLPublish1: TWSDLHTMLPublish;
procedure WebModule6DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModule6: TWebModule6;
implementation
{$R *.dfm}
procedure TWebModule6.WebModule6DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
WSDLHTMLPublish1.ServiceInfo(Sender, Request, Response, Handled);
end;
end.
Unit smod;
interface
uses SysUtils, Classes, InvokeRegistry, Midas, SOAPMidas, SOAPDm, Provider, DB,
DBTables, ADODB, DBClient;
type
Iws_smod = interface(IAppServerSOAP)
['{BA26B1ED-1B9B-4B58-B8A4-1A6380ADC64A}']
end;
Tws_smod = class(TSoapDataModule, Iws_smod, IAppServerSOAP, IAppServer)
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSetProvider1: TDataSetProvider;
ds2: TClientDataSet;
private
public
end;
implementation
{$R *.DFM}
procedure Tws_smodCreateInstance(out obj: TObject);
begin
obj := Tws_smod.Create(nil);
end;
initialization
InvRegistry.RegisterInvokableClass(Tws_smod, Tws_smodCreateInstance);
InvRegistry.RegisterInterface(TypeInfo(Iws_smod));
end.
客戶端代碼:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://10.106.59.120/webservice/ws_chkhj.dll/wsdl/Iws_chkhj
// Encoding : utf-8
// Version : 1.0
// (2016-7-25 11:43:20 - 1.33.2.5)
// ************************************************************************ //
unit Iws_chkhj6;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns,unyrecord;
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.
// ************************************************************************ //
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:tnyrecords - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Namespace : urn:ws_chkhjIntf-Iws_chkhj
// soapAction: urn:ws_chkhjIntf-Iws_chkhj#%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : Iws_chkhjbinding
// service : Iws_chkhjservice
// port : Iws_chkhjPort
// URL : http://10.106.59.120/webservice/ws_chkhj.dll/soap/Iws_chkhj
// ************************************************************************ //
Iws_chkhj = interface(IInvokable)
['{96F18753-A196-4142-29DF-0346361FFA0C}']
function sum(const x: Integer; const y: Integer): Integer; stdcall;
function getny: tnyrecords; stdcall;
end;
function GetIws_chkhj(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): Iws_chkhj;
implementation
function GetIws_chkhj(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): Iws_chkhj;
const
defWSDL = 'http://10.106.59.120/webservice/ws_chkhj.dll/wsdl/Iws_chkhj';
defURL = 'http://10.106.59.120/webservice/ws_chkhj.dll/soap/Iws_chkhj';
defSvc = 'Iws_chkhjservice';
defPrt = 'Iws_chkhjPort';
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 Iws_chkhj);
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;
initialization
InvRegistry.RegisterInterface(TypeInfo(Iws_chkhj), 'urn:ws_chkhjIntf-Iws_chkhj', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Iws_chkhj), 'urn:ws_chkhjIntf-Iws_chkhj#%operationName%');
end.
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, SOAPHTTPClient, Grids, DBGrids, StdCtrls,dm_client,
Buttons,ValEdit,ComCtrls,XSBuiltIns, Rio,unyrecord;
type
TForm6 = class(TForm)
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
lbl4: TLabel;
btn1: TButton;
cbb1: TComboBox;
cbb2: TComboBox;
cbb3: TComboBox;
cbb4: TComboBox;
dbgrd1: TDBGrid;
htpr1: THTTPRIO;
procedure FormCreate(Sender: TObject);
// procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses Iws_chkhj6,Types;
{$R *.dfm}
procedure TForm6.FormCreate(Sender: TObject);
var I:Integer;
//chkny:TStringDynArray;
chkny:tnyrecords;
s:string;
begin
chkny:=(htpr1 as Iws_chkhj).getny;
cbb1.Items.Clear;
for I:=Low(chkny) to High(chkny) do
begin
cbb1.Items.Add(chkny[I].ny);
end;
cbb1.Text:=cbb1.Items[0];
end;
end.
unit dm_client;
interface
uses
SysUtils, Classes, DB, DBClient, SOAPConn, Provider;
type
TDataModule1 = class(TDataModule)
con1: TSoapConnection;
ds1: TDataSource;
ds2: TClientDataSet;
private
{ Private declarations }
public
{ Public declarations }
end;
var
DataModule1: TDataModule1;
implementation
{$R *.dfm}
end.
nit unyrecord;
interface
uses
InvokeRegistry,XSBuiltIns;
type
Tnyrecord=class(TRemotable)
private
fny:string;
published
property ny:string read fny write fny;
end;
tnyrecords=array of Tnyrecord;
implementation
initialization
remclassregistry.RegisterXSClass(tnyrecord,'http://www.w3.org/2001/xmlschema','tnyrecord','',false);
remtyperegistry.RegisterXSInfo(TypeInfo(tnyrecords),'http://www.w3.org/2001/xmlschema','tnyrecords');
finalization
remclassregistry.UnRegisterXSClass(tnyrecord);
remtyperegistry.UnRegisterXSInfo(TypeInfo(tnyrecords));
end.
uj5u.com熱心網友回復:
傳輸前后以base64編碼解碼uj5u.com熱心網友回復:
如何進行base64編碼解碼,望指教。uj5u.com熱心網友回復:
如何進行base64編碼解碼,望指教!
uj5u.com熱心網友回復:
我使用的delphi studio2006, 不知道這個問題跟開發環境有關系嗎?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/66177.html
標籤:網絡通信/分布式開發
上一篇:mscomm 串口接收資料
下一篇:intraweb里控制元件TIWImageFile加載一個尺寸大的圖片,怎么讓超出TIWImageFile大小的部分不顯示?
