Our current project is in Delphi 6. This is my first time attempting to consume a web service in Delphi - my primary experience in this realm is with C#. Anyway, I need to consume a web service from this project. I've run into a bit of a problem, importing the wsdl (http://txportwst.txhubpr.com/txserver/1?wsdl) generates two units. There were a few issues with the units' type references and dependencies that kept it from building straight away, but I was able to correct those.
From a test form, I added code to consume the service, but I get an error which doesn't make sense. The method is expecting a var of the type (requestIVULoto) being sent in, but the error would indicate otherwise. I switched things up to a random service from xmethods.net, and was able to get a very simple one (reto. checkit.ch/Scripts/Lotto.dll/wsdl/IgetNumbers) functioning, which tells me that I'm on the right path, but then another (www. xmlme.com/WSDailyNet.asmx?WSDL) that was slightly more complicated didn't and generated the same error that I was receiving from the service I need to use.
I was able to get the service I need to use functioning in C# with a service ref and 10 lines of code which is easy but is making Delphi all the more frustrating. I'm considering a .net class lib exposed to com if this doesn't work. I'd rather do this natively in Delphi, but I fear Delphi 6 is just too old.
Any ideas?
As a side note, in C#..
IvuLoto.IvuSvc.ivuLotoData ild = new IvuLoto.IvuSvc.ivuLotoData();
ild = client.requestIVULoto(txn); // returns type ivuLotoData.
Error
---------------------------
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;
Units generated by wsdl import
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.
and
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.