使用Web服务 - Delphi 6

时间:2014-08-15 17:00:25

标签: delphi web service consuming

我们当前的项目是在Delphi 6中。这是我第一次尝试在Delphi中使用Web服务 - 我在这个领域的主要经验是使用C#。无论如何,我需要从这个项目中使用一个Web服务。我遇到了一些问题,导入wsdl(http://txportwst.txhubpr.com/txserver/1?wsdl)会生成两个单元。这些单位存在一些问题。类型引用和依赖,使它不能立即建立,但我能够纠正这些。

从测试表单中,我添加了使用该服务的代码,但是我收到了一个没有意义的错误。该方法期望发送类型的var(requestIVULoto),但错误将指示其他情况。我从xmethods.net切换到一个随机服务,并且能够得到一个非常简单的(reto.checkit.ch/Scripts/Lotto.dll/wsdl/IgetNumbers)功能,这告诉我我是在正确的道路上,但是稍微复杂的另一个(www.xmlme.com/WSDailyNet.asmx?WSDL)并没有产生我从我需要使用的服务收到的相同错误。

我能够在C#中使用服务参考和10行代码来获得我需要的服务,这很容易但是让Delphi更加令人沮丧。 如果这不起作用,我考虑将.net类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 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.

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.

1 个答案:

答案 0 :(得分:1)

我使用Delphi XE3导入了您指定的WSDL,并且无需任何修改即可正常工作(好的,我承认,我更改了单位名称)。

这是我收到的XML响应:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:requestIVULotoResponse xmlns:ns2="http://txserver.sut.softekpr.com/1">
      <IVULoto>
        <status>INVALID_PARAMETERS</status>
        <errorDetail>invalid merchantId</errorDetail>
      </IVULoto>
    </ns2:requestIVULotoResponse>
  </soap:Body>
</soap:Envelope>

这是我使用的代码:

procedure TFormMain.Button1Click(Sender: TObject);
var
  req : transaction;
  rsp : ivuLotoData;
  rio : THTTPRIO;
begin
  rio := THTTPRIO.Create(Self);
  //Compile request
  req := transaction.Create();
  req.txDate := TXSDateTime.Create;// '08/14/2014 00:00:00';
  req.txDate.AsDateTime := now;
  req.txType := txtype.SALE;
  req.merchantId := 'REMOVED';
  req.terminalId := IntToStr(112233);
  req.terminalPassword := 'REMOVED';
  req.txType := txType.SALE; //IVU.txType
  req.tenderType := tenderType.CASH; //IVU.tenderType
  req.subTotal := TXSDecimal.Create;
  req.subTotal.DecimalString := '100.00';
  req.municipalTax := TXSDecimal.Create;
  req.municipalTax.DecimalString := '1.00';
  req.stateTax := TXSDecimal.Create;
  req.stateTax.DecimalString := '6.00';
  req.total := TXSDecimal.Create;
  req.total.DecimalString := '107.00';

  //Call WS Method requestIVULoto
  rsp := GetTxServer(false, '', RIO).requestIVULoto(req);

   req.Free;
  rsp.Free;
end;

我已经研究过您的WSDL导入,但对Web服务的了解太少,无法对您的Delphi 6代码进行任何修改。

这是您的WSDL的Delphi XE3导入。我删除了大部分实现代码,因为Stack Overflow应答只能包含30000个字符。:

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://txportwst.txhubpr.com/txserver/1?wsdl
//  >Import : http://txportwst.txhubpr.com/txserver/1?wsdl>0
// Encoding : UTF-8
// Version  : 1.0
// (2014-08-16 08:43:38 - - $Rev: 52705 $)
// ************************************************************************ //

unit IVUSvc_wsdl;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_UNQL = $0008;


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 Embarcadero types; however, they could also 
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:decimal         - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:int             - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:dateTime        - "http://www.w3.org/2001/XMLSchema"[Gbl]

  ivuLotoData          = class;                 { "http://txserver.sut.softekpr.com/1"[GblCplx] }
  txInfoResponse       = class;                 { "http://txserver.sut.softekpr.com/1"[GblCplx] }
  transaction          = class;                 { "http://txserver.sut.softekpr.com/1"[GblCplx] }
  txInfo               = class;                 { "http://txserver.sut.softekpr.com/1"[GblCplx] }
  txInfoRequest        = class;                 { "http://txserver.sut.softekpr.com/1"[GblCplx] }

  {$SCOPEDENUMS ON}
  { "http://txserver.sut.softekpr.com/1"[GblSmpl] }
  txInfoResponseStatus = (SUCCESS, AUTHENTICATION_FAILED, MISSING_PARAMETERS, INVALID_PARAMETERS, SERVER_ERROR);

  { "http://txserver.sut.softekpr.com/1"[GblSmpl] }
  txPosResponseStatus = (SUCCESS, AUTHENTICATION_FAILED, MISSING_PARAMETERS, INVALID_PARAMETERS, SERVER_ERROR);

  { "http://txserver.sut.softekpr.com/1"[GblSmpl] }
  txType = (SALE, REFUND);

  { "http://txserver.sut.softekpr.com/1"[GblSmpl] }
  tenderType = (CASH, CREDIT, DEBIT, EBT, ATH, UNSPECIFIED_CARD, UNKNOWN);

  {$SCOPEDENUMS OFF}

  Array_Of_txInfo = array of txInfo;            { "http://txserver.sut.softekpr.com/1"[GblUbnd] }


  // ************************************************************************ //
  // XML       : ivuLotoData, global, <complexType>
  // Namespace : http://txserver.sut.softekpr.com/1
  // ************************************************************************ //
  ivuLotoData = class(TRemotable)
  private
    FivuLoto: string;
    FivuLoto_Specified: boolean;
    FcontrolNumber: string;
    FcontrolNumber_Specified: boolean;
    FdrawNumber: string;
    FdrawNumber_Specified: boolean;
    FdrawDate: TXSDateTime;
    FdrawDate_Specified: boolean;
    Fstatus: txPosResponseStatus;
    Fstatus_Specified: boolean;
    FerrorDetail: string;
    FerrorDetail_Specified: boolean;
    procedure SetivuLoto(Index: Integer; const Astring: string);
    function  ivuLoto_Specified(Index: Integer): boolean;
    procedure SetcontrolNumber(Index: Integer; const Astring: string);
    function  controlNumber_Specified(Index: Integer): boolean;
    procedure SetdrawNumber(Index: Integer; const Astring: string);
    function  drawNumber_Specified(Index: Integer): boolean;
    procedure SetdrawDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  drawDate_Specified(Index: Integer): boolean;
    procedure Setstatus(Index: Integer; const AtxPosResponseStatus: txPosResponseStatus);
    function  status_Specified(Index: Integer): boolean;
    procedure SeterrorDetail(Index: Integer; const Astring: string);
    function  errorDetail_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property ivuLoto:       string               Index (IS_OPTN or IS_UNQL) read FivuLoto write SetivuLoto stored ivuLoto_Specified;
    property controlNumber: string               Index (IS_OPTN or IS_UNQL) read FcontrolNumber write SetcontrolNumber stored controlNumber_Specified;
    property drawNumber:    string               Index (IS_OPTN or IS_UNQL) read FdrawNumber write SetdrawNumber stored drawNumber_Specified;
    property drawDate:      TXSDateTime          Index (IS_OPTN or IS_UNQL) read FdrawDate write SetdrawDate stored drawDate_Specified;
    property status:        txPosResponseStatus  Index (IS_OPTN or IS_UNQL) read Fstatus write Setstatus stored status_Specified;
    property errorDetail:   string               Index (IS_OPTN or IS_UNQL) read FerrorDetail write SeterrorDetail stored errorDetail_Specified;
  end;



  // ************************************************************************ //
  // XML       : txInfoResponse, global, <complexType>
  // Namespace : http://txserver.sut.softekpr.com/1
  // ************************************************************************ //
  txInfoResponse = class(TRemotable)
  private
    FerrorDetail: string;
    FerrorDetail_Specified: boolean;
    FtxCount: Integer;
    Ftransactions: Array_Of_txInfo;
    Ftransactions_Specified: boolean;
    Fstatus: txInfoResponseStatus;
    Fstatus_Specified: boolean;
    procedure SeterrorDetail(Index: Integer; const Astring: string);
    function  errorDetail_Specified(Index: Integer): boolean;
    procedure Settransactions(Index: Integer; const AArray_Of_txInfo: Array_Of_txInfo);
    function  transactions_Specified(Index: Integer): boolean;
    procedure Setstatus(Index: Integer; const AtxInfoResponseStatus: txInfoResponseStatus);
    function  status_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property errorDetail:  string                Index (IS_OPTN or IS_UNQL) read FerrorDetail write SeterrorDetail stored errorDetail_Specified;
    property txCount:      Integer               Index (IS_UNQL) read FtxCount write FtxCount;
    property transactions: Array_Of_txInfo       Index (IS_OPTN or IS_UNBD or IS_UNQL) read Ftransactions write Settransactions stored transactions_Specified;
    property status:       txInfoResponseStatus  Index (IS_OPTN or IS_UNQL) read Fstatus write Setstatus stored status_Specified;
  end;



  // ************************************************************************ //
  // XML       : transaction, global, <complexType>
  // Namespace : http://txserver.sut.softekpr.com/1
  // ************************************************************************ //
  transaction = class(TRemotable)
  private
    FmerchantId: string;
    FmerchantId_Specified: boolean;
    FmunicipalTax: TXSDecimal;
    FmunicipalTax_Specified: boolean;
    FstateTax: TXSDecimal;
    FstateTax_Specified: boolean;
    FsubTotal: TXSDecimal;
    FsubTotal_Specified: boolean;
    FtenderType: tenderType;
    FtenderType_Specified: boolean;
    FterminalId: string;
    FterminalId_Specified: boolean;
    FterminalPassword: string;
    FterminalPassword_Specified: boolean;
    Ftotal: TXSDecimal;
    Ftotal_Specified: boolean;
    FtxDate: TXSDateTime;
    FtxDate_Specified: boolean;
    FtxType: txType;
    FtxType_Specified: boolean;
    procedure SetmerchantId(Index: Integer; const Astring: string);
    function  merchantId_Specified(Index: Integer): boolean;
    procedure SetmunicipalTax(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  municipalTax_Specified(Index: Integer): boolean;
    procedure SetstateTax(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  stateTax_Specified(Index: Integer): boolean;
    procedure SetsubTotal(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  subTotal_Specified(Index: Integer): boolean;
    procedure SettenderType(Index: Integer; const AtenderType: tenderType);
    function  tenderType_Specified(Index: Integer): boolean;
    procedure SetterminalId(Index: Integer; const Astring: string);
    function  terminalId_Specified(Index: Integer): boolean;
    procedure SetterminalPassword(Index: Integer; const Astring: string);
    function  terminalPassword_Specified(Index: Integer): boolean;
    procedure Settotal(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  total_Specified(Index: Integer): boolean;
    procedure SettxDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  txDate_Specified(Index: Integer): boolean;
    procedure SettxType(Index: Integer; const AtxType: txType);
    function  txType_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property merchantId:       string       Index (IS_OPTN or IS_UNQL) read FmerchantId write SetmerchantId stored merchantId_Specified;
    property municipalTax:     TXSDecimal   Index (IS_OPTN or IS_UNQL) read FmunicipalTax write SetmunicipalTax stored municipalTax_Specified;
    property stateTax:         TXSDecimal   Index (IS_OPTN or IS_UNQL) read FstateTax write SetstateTax stored stateTax_Specified;
    property subTotal:         TXSDecimal   Index (IS_OPTN or IS_UNQL) read FsubTotal write SetsubTotal stored subTotal_Specified;
    property tenderType:       tenderType   Index (IS_OPTN or IS_UNQL) read FtenderType write SettenderType stored tenderType_Specified;
    property terminalId:       string       Index (IS_OPTN or IS_UNQL) read FterminalId write SetterminalId stored terminalId_Specified;
    property terminalPassword: string       Index (IS_OPTN or IS_UNQL) read FterminalPassword write SetterminalPassword stored terminalPassword_Specified;
    property total:            TXSDecimal   Index (IS_OPTN or IS_UNQL) read Ftotal write Settotal stored total_Specified;
    property txDate:           TXSDateTime  Index (IS_OPTN or IS_UNQL) read FtxDate write SettxDate stored txDate_Specified;
    property txType:           txType       Index (IS_OPTN or IS_UNQL) read FtxType write SettxType stored txType_Specified;
  end;



  // ************************************************************************ //
  // XML       : txInfo, global, <complexType>
  // Namespace : http://txserver.sut.softekpr.com/1
  // ************************************************************************ //
  txInfo = class(TRemotable)
  private
    FcontrolNumber: string;
    FcontrolNumber_Specified: boolean;
    FdrawDate: TXSDateTime;
    FdrawDate_Specified: boolean;
    FdrawNumber: string;
    FdrawNumber_Specified: boolean;
    FivuLottoNumber: string;
    FivuLottoNumber_Specified: boolean;
    FmunicipalTax: TXSDecimal;
    FmunicipalTax_Specified: boolean;
    FstateTax: TXSDecimal;
    FstateTax_Specified: boolean;
    FsubTotal: TXSDecimal;
    FsubTotal_Specified: boolean;
    FtenderType: tenderType;
    FtenderType_Specified: boolean;
    Ftotal: TXSDecimal;
    Ftotal_Specified: boolean;
    FtransactionDate: TXSDateTime;
    FtransactionDate_Specified: boolean;
    FtransactionType: txType;
    FtransactionType_Specified: boolean;
    procedure SetcontrolNumber(Index: Integer; const Astring: string);
    function  controlNumber_Specified(Index: Integer): boolean;
    procedure SetdrawDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  drawDate_Specified(Index: Integer): boolean;
    procedure SetdrawNumber(Index: Integer; const Astring: string);
    function  drawNumber_Specified(Index: Integer): boolean;
    procedure SetivuLottoNumber(Index: Integer; const Astring: string);
    function  ivuLottoNumber_Specified(Index: Integer): boolean;
    procedure SetmunicipalTax(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  municipalTax_Specified(Index: Integer): boolean;
    procedure SetstateTax(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  stateTax_Specified(Index: Integer): boolean;
    procedure SetsubTotal(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  subTotal_Specified(Index: Integer): boolean;
    procedure SettenderType(Index: Integer; const AtenderType: tenderType);
    function  tenderType_Specified(Index: Integer): boolean;
    procedure Settotal(Index: Integer; const ATXSDecimal: TXSDecimal);
    function  total_Specified(Index: Integer): boolean;
    procedure SettransactionDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  transactionDate_Specified(Index: Integer): boolean;
    procedure SettransactionType(Index: Integer; const AtxType: txType);
    function  transactionType_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property controlNumber:   string       Index (IS_OPTN or IS_UNQL) read FcontrolNumber write SetcontrolNumber stored controlNumber_Specified;
    property drawDate:        TXSDateTime  Index (IS_OPTN or IS_UNQL) read FdrawDate write SetdrawDate stored drawDate_Specified;
    property drawNumber:      string       Index (IS_OPTN or IS_UNQL) read FdrawNumber write SetdrawNumber stored drawNumber_Specified;
    property ivuLottoNumber:  string       Index (IS_OPTN or IS_UNQL) read FivuLottoNumber write SetivuLottoNumber stored ivuLottoNumber_Specified;
    property municipalTax:    TXSDecimal   Index (IS_OPTN or IS_UNQL) read FmunicipalTax write SetmunicipalTax stored municipalTax_Specified;
    property stateTax:        TXSDecimal   Index (IS_OPTN or IS_UNQL) read FstateTax write SetstateTax stored stateTax_Specified;
    property subTotal:        TXSDecimal   Index (IS_OPTN or IS_UNQL) read FsubTotal write SetsubTotal stored subTotal_Specified;
    property tenderType:      tenderType   Index (IS_OPTN or IS_UNQL) read FtenderType write SettenderType stored tenderType_Specified;
    property total:           TXSDecimal   Index (IS_OPTN or IS_UNQL) read Ftotal write Settotal stored total_Specified;
    property transactionDate: TXSDateTime  Index (IS_OPTN or IS_UNQL) read FtransactionDate write SettransactionDate stored transactionDate_Specified;
    property transactionType: txType       Index (IS_OPTN or IS_UNQL) read FtransactionType write SettransactionType stored transactionType_Specified;
  end;



  // ************************************************************************ //
  // XML       : txInfoRequest, global, <complexType>
  // Namespace : http://txserver.sut.softekpr.com/1
  // ************************************************************************ //
  txInfoRequest = class(TRemotable)
  private
    FendDate: TXSDateTime;
    FendDate_Specified: boolean;
    FmerchantId: string;
    FmerchantId_Specified: boolean;
    FstartDate: TXSDateTime;
    FstartDate_Specified: boolean;
    FterminalId: string;
    FterminalId_Specified: boolean;
    FterminalPassword: string;
    FterminalPassword_Specified: boolean;
    procedure SetendDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  endDate_Specified(Index: Integer): boolean;
    procedure SetmerchantId(Index: Integer; const Astring: string);
    function  merchantId_Specified(Index: Integer): boolean;
    procedure SetstartDate(Index: Integer; const ATXSDateTime: TXSDateTime);
    function  startDate_Specified(Index: Integer): boolean;
    procedure SetterminalId(Index: Integer; const Astring: string);
    function  terminalId_Specified(Index: Integer): boolean;
    procedure SetterminalPassword(Index: Integer; const Astring: string);
    function  terminalPassword_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property endDate:          TXSDateTime  Index (IS_OPTN or IS_UNQL) read FendDate write SetendDate stored endDate_Specified;
    property merchantId:       string       Index (IS_OPTN or IS_UNQL) read FmerchantId write SetmerchantId stored merchantId_Specified;
    property startDate:        TXSDateTime  Index (IS_OPTN or IS_UNQL) read FstartDate write SetstartDate stored startDate_Specified;
    property terminalId:       string       Index (IS_OPTN or IS_UNQL) read FterminalId write SetterminalId stored terminalId_Specified;
    property terminalPassword: string       Index (IS_OPTN or IS_UNQL) read FterminalPassword write SetterminalPassword stored terminalPassword_Specified;
  end;


  // ************************************************************************ //
  // Namespace : http://txserver.sut.softekpr.com/1
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : TxServerServiceSoapBinding
  // service   : TxServerService
  // port      : TxServerPort
  // URL       : http://txportwst.txhubpr.com/txserver/1
  // ************************************************************************ //
  TxServer = interface(IInvokable)
  ['{FA236F41-8840-15A4-8F74-1E1583384A66}']
    function  requestIVULoto(const transaction: transaction): ivuLotoData; stdcall;
    function  requestTxInfo(const arg0: txInfoRequest): txInfoResponse; stdcall;
  end;

function GetTxServer(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): TxServer;


implementation
  uses SysUtils;

function GetTxServer(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): TxServer;
const
  defWSDL = 'http://txportwst.txhubpr.com/txserver/1?wsdl';
  defURL  = 'http://txportwst.txhubpr.com/txserver/1';
  defSvc  = 'TxServerService';
  defPrt  = 'TxServerPort';
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 TxServer);
    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;


//I removed implementation because Stack Overflow answer can only contain 30000 characters 

initialization
  { TxServer }
  InvRegistry.RegisterInterface(TypeInfo(TxServer), 'http://txserver.sut.softekpr.com/1', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(TxServer), '');
  InvRegistry.RegisterInvokeOptions(TypeInfo(TxServer), ioDocument);
  { TxServer.requestIVULoto }
  InvRegistry.RegisterMethodInfo(TypeInfo(TxServer), 'requestIVULoto', '',
                                 '[ReturnName="IVULoto"]', IS_OPTN or IS_UNQL);
  InvRegistry.RegisterParamInfo(TypeInfo(TxServer), 'requestIVULoto', 'transaction', '',
                                '', IS_UNQL);
  InvRegistry.RegisterParamInfo(TypeInfo(TxServer), 'requestIVULoto', 'IVULoto', '',
                                '', IS_UNQL);
  { TxServer.requestTxInfo }
  InvRegistry.RegisterMethodInfo(TypeInfo(TxServer), 'requestTxInfo', '',
                                 '[ReturnName="return"]', IS_OPTN or IS_UNQL);
  InvRegistry.RegisterParamInfo(TypeInfo(TxServer), 'requestTxInfo', 'arg0', '',
                                '', IS_UNQL);
  InvRegistry.RegisterParamInfo(TypeInfo(TxServer), 'requestTxInfo', 'return', '',
                                '', IS_UNQL);
  RemClassRegistry.RegisterXSInfo(TypeInfo(txInfoResponseStatus), 'http://txserver.sut.softekpr.com/1', 'txInfoResponseStatus');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_txInfo), 'http://txserver.sut.softekpr.com/1', 'Array_Of_txInfo');
  RemClassRegistry.RegisterXSInfo(TypeInfo(txPosResponseStatus), 'http://txserver.sut.softekpr.com/1', 'txPosResponseStatus');
  RemClassRegistry.RegisterXSInfo(TypeInfo(txType), 'http://txserver.sut.softekpr.com/1', 'txType');
  RemClassRegistry.RegisterXSClass(ivuLotoData, 'http://txserver.sut.softekpr.com/1', 'ivuLotoData');
  RemClassRegistry.RegisterXSClass(txInfoResponse, 'http://txserver.sut.softekpr.com/1', 'txInfoResponse');
  RemClassRegistry.RegisterXSInfo(TypeInfo(tenderType), 'http://txserver.sut.softekpr.com/1', 'tenderType');
  RemClassRegistry.RegisterXSClass(transaction, 'http://txserver.sut.softekpr.com/1', 'transaction');
  RemClassRegistry.RegisterXSClass(txInfo, 'http://txserver.sut.softekpr.com/1', 'txInfo');
  RemClassRegistry.RegisterXSClass(txInfoRequest, 'http://txserver.sut.softekpr.com/1', 'txInfoRequest');

end.