Текущият ни проект е в Delphi 6. Това е първият ми опит да използвам уеб услуга в Delphi - основният ми опит в тази област е с C#. Както и да е, трябва да използвам уеб услуга от този проект. Сблъсках се с малък проблем при импортирането на wsdl (http://txportwst.txhubpr.com/txserver/1?wsdl) генерира две единици. Имаше няколко проблема с препратките към типове на единиците и зависимостите, които не позволяваха изграждането му веднага, но успях да ги коригирам.
От тестова форма добавих код за използване на услугата, но получавам грешка, която няма смисъл. Методът очаква да бъде изпратена променлива от типа (requestIVULoto), но грешката ще покаже друго. Превключих нещата към произволна услуга от xmethods.net и успях да накарам една много проста (reto. checkit.ch/Scripts/Lotto.dll/wsdl/IgetNumbers) да функционира, което ми казва, че съм на прав път, но след това друг (www. xmlme.com/WSDailyNet.asmx?WSDL), който беше малко по-сложен, не го направи и генерира същата грешка, която получавах от услугата, която трябва да използвам.
Успях да накарам услугата, която трябва да използвам, да функционира в C# с реф на услугата и 10 реда код, което е лесно, но прави Delphi още по-разочароващо. Обмислям .net class lib, изложен на com, ако това не работи. Предпочитам да направя това в Delphi, но се опасявам, че Delphi 6 е твърде стар.
Някакви идеи?
Като странична бележка, в C#..
IvuLoto.IvuSvc.ivuLotoData ild = new IvuLoto.IvuSvc.ivuLotoData();
ild = client.requestIVULoto(txn); // returns type ivuLotoData.
Грешка
---------------------------
Debugger Exception Notification
---------------------------
Project TEST.exe raised exception class Exception with message 'The parameter is incorrect.'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
TestForm
...
implementation
uses
IVU, IVUSvc;
...
procedure TFormTest.Button1Click(Sender: TObject);
var
ivu: requestIVULoto;
txn: transaction;
rio: THTTPRIO;
begin
rio := THTTPRIO.Create(nil);
rio.wsdlLocation := 'http://txportwst.txhubpr.com/txserver/1?wsdl';
rio.Service := 'txServerService';
rio.Port := 'txServerPort';
txn := transaction.Create();
txn.txDate := '08/14/2014 00:00:00';
txn.merchantId := 'REMOVED';
txn.terminalId := IntToStr(Workstation.WorkstationId);
txn.terminalPassword := 'REMOVED';
txn.txType := SALE; //IVU.txType
txn.tenderType := CASH; //IVU.tenderType
txn.subTotal := '100.00';
txn.municipalTax := '1.00';
txn.stateTax := '6.00';
txn.total := '107.00';
ivu := requestIVULoto.Create();
ivu.transaction := txn;
(rio as txServer).requestIVULoto(ivu);
rio.Free;
ivu.Free;
txn.Free;
end;
Единици, генерирани от wsdl импортиране
Unit IVUSvc;
interface
uses Types, XSBuiltIns, IVU;
type
TxServer = interface(IInvokable)
['{07415916-265C-448F-B69F-0AAF9CBDDC1C}']
procedure requestIVULoto(var parameters: requestIVULoto); stdcall;
procedure requestTxInfo(var parameters: requestTxInfo); stdcall;
end;
implementation
uses InvokeRegistry;
initialization
InvRegistry.RegisterInterface(TypeInfo(TxServer), '', 'UTF-8');
end.
и
Unit IVU;
interface
uses InvokeRegistry, Types, XSBuiltIns, XMLDoc;
type
requestIVULoto = class;
transaction = class;
requestIVULotoResponse = class;
ivuLotoData = class;
requestTxInfo = class;
txInfoRequest = class;
requestTxInfoResponse = class;
txInfoResponse = class;
txInfo = class;
{ tenderType }
tenderType = (CASH, CREDIT, DEBIT, EBT, ATH, UNSPECIFIED_CARD, UNKNOWN);
{ txType }
txType = (SALE, REFUND);
{ txPosResponseStatus }
txPosResponseStatus = (SUCCESS, AUTHENTICATION_FAILED, MISSING_PARAMETERS, INVALID_PARAMETERS, SERVER_ERROR);
{ txInfoResponseStatus }
txInfoResponseStatus = txPosResponseStatus;//(SUCCESS, AUTHENTICATION_FAILED, MISSING_PARAMETERS, INVALID_PARAMETERS, SERVER_ERROR);
{ requestIVULoto }
requestIVULoto = class(TRemotable)
private
Ftransaction: transaction;
published
property transaction: transaction read Ftransaction write Ftransaction;
end;
{ transaction }
transaction = class(TRemotable)
private
FmerchantId: WideString;
FmunicipalTax: WideString;
FstateTax: WideString;
FsubTotal: WideString;
FtenderType: tenderType;
FterminalId: WideString;
FterminalPassword: WideString;
Ftotal: WideString;
FtxDate: WideString;
FtxType: txType;
published
property merchantId: WideString read FmerchantId write FmerchantId;
property municipalTax: WideString read FmunicipalTax write FmunicipalTax;
property stateTax: WideString read FstateTax write FstateTax;
property subTotal: WideString read FsubTotal write FsubTotal;
property tenderType: tenderType read FtenderType write FtenderType;
property terminalId: WideString read FterminalId write FterminalId;
property terminalPassword: WideString read FterminalPassword write FterminalPassword;
property total: WideString read Ftotal write Ftotal;
property txDate: WideString read FtxDate write FtxDate;
property txType: txType read FtxType write FtxType;
end;
{ requestIVULotoResponse }
requestIVULotoResponse = class(TRemotable)
private
FIVULoto: ivuLotoData;
published
property IVULoto: ivuLotoData read FIVULoto write FIVULoto;
end;
{ ivuLotoData }
ivuLotoData = class(TRemotable)
private
FivuLoto: WideString;
FcontrolNumber: WideString;
FdrawNumber: WideString;
FdrawDate: WideString;
Fstatus: txPosResponseStatus;
FerrorDetail: WideString;
published
property ivuLoto: WideString read FivuLoto write FivuLoto;
property controlNumber: WideString read FcontrolNumber write FcontrolNumber;
property drawNumber: WideString read FdrawNumber write FdrawNumber;
property drawDate: WideString read FdrawDate write FdrawDate;
property status: txPosResponseStatus read Fstatus write Fstatus;
property errorDetail: WideString read FerrorDetail write FerrorDetail;
end;
{ requestTxInfo }
requestTxInfo = class(TRemotable)
private
Farg0: txInfoRequest;
published
property arg0: txInfoRequest read Farg0 write Farg0;
end;
{ txInfoRequest }
txInfoRequest = class(TRemotable)
private
FendDate: WideString;
FmerchantId: WideString;
FstartDate: WideString;
FterminalId: WideString;
FterminalPassword: WideString;
published
property endDate: WideString read FendDate write FendDate;
property merchantId: WideString read FmerchantId write FmerchantId;
property startDate: WideString read FstartDate write FstartDate;
property terminalId: WideString read FterminalId write FterminalId;
property terminalPassword: WideString read FterminalPassword write FterminalPassword;
end;
{ requestTxInfoResponse }
requestTxInfoResponse = class(TRemotable)
private
Freturn: txInfoResponse;
published
property return: txInfoResponse read Freturn write Freturn;
end;
{ txInfo }
txInfo = class(TRemotable)
private
FcontrolNumber: WideString;
FdrawDate: WideString;
FdrawNumber: WideString;
FivuLottoNumber: WideString;
FmunicipalTax: WideString;
FstateTax: WideString;
FsubTotal: WideString;
FtenderType: tenderType;
Ftotal: WideString;
FtransactionDate: WideString;
FtransactionType: txType;
published
property controlNumber: WideString read FcontrolNumber write FcontrolNumber;
property drawDate: WideString read FdrawDate write FdrawDate;
property drawNumber: WideString read FdrawNumber write FdrawNumber;
property ivuLottoNumber: WideString read FivuLottoNumber write FivuLottoNumber;
property municipalTax: WideString read FmunicipalTax write FmunicipalTax;
property stateTax: WideString read FstateTax write FstateTax;
property subTotal: WideString read FsubTotal write FsubTotal;
property tenderType: tenderType read FtenderType write FtenderType;
property total: WideString read Ftotal write Ftotal;
property transactionDate: WideString read FtransactionDate write FtransactionDate;
property transactionType: txType read FtransactionType write FtransactionType;
end;
{ txInfoList }
txInfoList = class(TXMLNodeCollection)
end;
{ txInfoResponse }
txInfoResponse = class(TRemotable)
private
FerrorDetail: WideString;
FtxCount: Integer;
Ftransactions: txInfoList;
Fstatus: txInfoResponseStatus;
published
property errorDetail: WideString read FerrorDetail write FerrorDetail;
property txCount: Integer read FtxCount write FtxCount;
property transactions: txInfoList read Ftransactions write Ftransactions;
property status: txInfoResponseStatus read Fstatus write Fstatus;
end;
implementation
initialization
RemClassRegistry.RegisterXSInfo(TypeInfo(tenderType),'http://txserver.sut.softekpr.com/1','tenderType','');
RemClassRegistry.RegisterXSInfo(TypeInfo(txType),'http://txserver.sut.softekpr.com/1','txType','');
RemClassRegistry.RegisterXSInfo(TypeInfo(txPosResponseStatus),'http://txserver.sut.softekpr.com/1','txPosResponseStatus','');
RemClassRegistry.RegisterXSInfo(TypeInfo(txInfoResponseStatus),'http://txserver.sut.softekpr.com/1','txInfoResponseStatus','');
RemClassRegistry.RegisterXSInfo(TypeInfo(requestIVULoto),'http://txserver.sut.softekpr.com/1','requestIVULoto','');
RemClassRegistry.RegisterXSInfo(TypeInfo(requestIVULotoResponse),'http://txserver.sut.softekpr.com/1','requestIVULotoResponse','');
RemClassRegistry.RegisterXSInfo(TypeInfo(requestTxInfo),'http://txserver.sut.softekpr.com/1','requestTxInfo','');
RemClassRegistry.RegisterXSInfo(TypeInfo(requestTxInfoResponse),'http://txserver.sut.softekpr.com/1','requestTxInfoResponse','');
RemClassRegistry.RegisterXSClass(requestIVULoto,'http://txserver.sut.softekpr.com/1','requestIVULoto','');
RemClassRegistry.RegisterXSClass(transaction,'http://txserver.sut.softekpr.com/1','transaction','');
RemClassRegistry.RegisterXSClass(requestIVULotoResponse,'http://txserver.sut.softekpr.com/1','requestIVULotoResponse','');
RemClassRegistry.RegisterXSClass(ivuLotoData,'http://txserver.sut.softekpr.com/1','ivuLotoData','');
RemClassRegistry.RegisterXSClass(requestTxInfo,'http://txserver.sut.softekpr.com/1','requestTxInfo','');
RemClassRegistry.RegisterXSClass(txInfoRequest,'http://txserver.sut.softekpr.com/1','txInfoRequest','');
RemClassRegistry.RegisterXSClass(requestTxInfoResponse,'http://txserver.sut.softekpr.com/1','requestTxInfoResponse','');
RemClassRegistry.RegisterXSClass(txInfoResponse,'http://txserver.sut.softekpr.com/1','txInfoResponse','');
RemClassRegistry.RegisterXSClass(txInfo,'http://txserver.sut.softekpr.com/1','txInfo','');
end.