我已经做了一个 cgi web 服务。代码如下:
unit MyServicesImpl;
interface
uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, MyServicesIntf,
Data.DB,
Data.SqlExpr, SQLConnection1, Data.Win.ADODB;
type
{ TMyServices }
TMyServices = class(TInvokableClass, IMyServices)
public
function TestFunction(): TADODataSet; stdcall;
end;
var
ConnString: string;
objTADOQuery: TADOQuery;
objTSQLDS: TDataSource;
objDS: TADODataSet;
objTable :TADOTable;
implementation
function TMyServices.TestFunction: TADODataSet;
var
objTSQLConnection1: TADOConnection;
var
conStr: string;
begin
objTSQLConnection1 := TADOConnection.Create(nil);
conStr := 'Provider=sqloledb;' + 'Data Source=Kays-serv64-01;' +
'Initial Catalog=Test;' + 'User Id=sa;Password=Kays@India';
objTSQLConnection1.ConnectionString := conStr;
objTSQLConnection1.LoginPrompt := False;
objTSQLConnection1.Connected := True;
if (objTSQLConnection1.Connected) then
begin
objTADOQuery := TADOQuery.Create(nil);
objTSQLDS := TDataSource.Create(nil);
objDS:= TADODataSet.Create(nil);
objTable:= TADOTable.Create(nil);
objTable.TableName:='expediads';
objTADOQuery.Connection := objTSQLConnection1;
objTADOQuery.SQL.Text := 'select * from expediads';
objTADOQuery.Prepared := True;
objTADOQuery.Active := True;
objTSQLDS.DataSet := objTADOQuery;
objDS.DataSource:=objTSQLDS;
Result := objDS;
end
else
begin
Result := objDS;
end;
end;
initialization
{ Invokable classes must be registered }
InvRegistry.RegisterInvokableClass(TMyServices);
end.
现在我正在尝试使用这个 web 服务,我使用了一个导入的 wsdl。但是当我像这样使用它时:
Procedure TForm3.TestFunction;
var
vMyService: IMyServices;
var
objDataSource: TDataSource;
var
objNewDS: IMyServices1.TADODataSet;
var
objTSQLConnection1: TADOConnection;
var
conStr: string;
begin
vMyService := GetIMyServices;
objNewDS :=vMyService.TestFunction();
end;
Test 函数返回 IMyservice1.TADODataset nad,因此与 Data.DB.TADODataset 不兼容。请帮忙。