开发者

Delphi 2010 or c# - webservice

开发者 https://www.devze.com 2023-02-04 22:47 出处:网络
I am trying use webserivce with Delphi 2010 but i cant get the gettransaction to work right. How do i use delphi to get the reponse from this function? I can insert the parameter to call it but not ge

I am trying use webserivce with Delphi 2010 but i cant get the gettransaction to work right. How do i use delphi to get the reponse from this function? I can insert the parameter to call it but not get the response.

How can i use the Delphi or c# to read the repsonse?

This is the XML:

<?xml version="1.0" encoding="UTF-8"?>

      <xsd:complexType name="getTransactions">
        <xsd:sequence>
          <xsd:element name="date_from" nillable="true" type="xsd:string"/>
          <xsd:element name="date_to" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="getTransactionsResponse">
        <xsd:sequence>
          <xsd:element name="voucherTransactions" nillable="true" type="tns:ArrayOfVoucherTransaction"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="VoucherTransaction">
        <xsd:sequence>
          <xsd:element name="GLOBAL_SERIAL_NUMBER" nillable="true" ty开发者_运维百科pe="xsd:string"/>
          <xsd:element name="DATE_CREATED" nillable="true" type="xsd:string"/>
          <xsd:element name="AMOUNT" nillable="true" type="xsd:string"/>
          <xsd:element name="STATUS" nillable="true" type="xsd:string"/>
          <xsd:element name="PIN_CODE" nillable="true" type="xsd:string"/>
          <xsd:element name="EXT_REF" nillable="true" type="xsd:string"/>
          <xsd:element name="STORE_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="TERMINAL_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="EMP_ID" nillable="true" type="xsd:string"/>
          <xsd:element name="DATE_INVALIDATED" nillable="true" type="xsd:string"/>
          <xsd:element name="EXPIRY_DATE" nillable="true" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfVoucherTransaction"><xsd:sequence>

      </xsd:complexType>
             <xsd:element name="getTransactions" type="tns:getTransactions"/>

I call the webserive with gettransaction with parameter From 01.01.2011 and To 17.01.2011

This is the function look like in delphi 2010

procedure TForm2.Button2Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2; 
  getrr    : voucher17.getTransactionsResponse2;
  aa2    : voucher17.ArrayOfVoucherTransaction;
  iinn   : integer; 
  test3  : voucher17.VoucherTransaction; 
  test4  : voucher17.ArrayOfVoucherTransaction;
begin


rr := getTransactions2.Create;
rr.date_from := '09.01.2011';
rr.date_to   := '10.01.2011';

getrr := GetVoucher_PortType.getTransactions(rr);

// here is the problem but i dont know how to read from the array
 i have try to assign getrr to test3, test4, aa2 but still cant figure out what to do to get the data.

end;

This is the return from soapui so this is working but how can use delphi to read from this?

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <SOAP-ENV:Header xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"/>

   <SOAP-ENV:Body>

      <ser-root:getTransactionsResponse xmlns:ser-root="https://webmethods.someurl.com/TopUpServices/webServices/Voucher">

         <voucherTransactions>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3132765</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

            <ArrayOfVoucherTransactionItem>

               <GLOBAL_SERIAL_NUMBER>3133023</GLOBAL_SERIAL_NUMBER>

               <DATE_CREATED>2011-01-17 20:34:49.0</DATE_CREATED>

               <AMOUNT>500</AMOUNT>

               <STATUS>1</STATUS>

               <PIN_CODE>123</PIN_CODE>

               <EXT_REF>772</EXT_REF>

               <STORE_ID>772</STORE_ID>

               <TERMINAL_ID>772</TERMINAL_ID>

               <EMP_ID>772</EMP_ID>

               <DATE_INVALIDATED>2011-01-17 20:34:49.0</DATE_INVALIDATED>

               <EXPIRY_DATE>2011-01-17 20:34:49.0</EXPIRY_DATE>

            </ArrayOfVoucherTransactionItem>

         </voucherTransactions>

      </ser-root:getTransactionsResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Here is the proxy

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described beloow:
// WSDL     : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL
//  >Import : https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL>0
// Encoding : UTF-8
// Codegen  : [wfAutoDestroyMembers-, wfMapArraysToClasses+, wfProcessHeaders-, wfUseSettersAndGetters+, wfForceSOAP11+, wfForceSOAP12+]
// Version  : 1.0
// (10.1.2011 15:31:05 - - $Rev: 25127 $)
// ************************************************************************ //

unit Voucher17;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns, Dialogs;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_NLBL = $0004;
  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.
  // ************************************************************************ //
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]

  getTransactions      = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  getTransactionsResponse = class;              { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblCplx] }
  VoucherTransaction   = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }
  getTransactions2     = class;                 { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  getTransactionsResponse2 = class;             { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[Lit][GblElm] }
  ArrayOfVoucherTransaction = class;            { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblCplx] }


  // ************************************************************************ //
  // XML       : getTransactions, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions = class(TRemotable)
  private
    Fdate_from: string;
    Fdate_to: string;
    function  Getdate_from(Index: Integer): string;
    procedure Setdate_from(Index: Integer; const Astring: string);
    function  Getdate_to(Index: Integer): string;
    procedure Setdate_to(Index: Integer; const Astring: string);
  public
    constructor Create; override;
  published
    property date_from: string  Index (IS_NLBL or IS_UNQL) read Getdate_from write Setdate_from;
    property date_to:   string  Index (IS_NLBL or IS_UNQL) read Getdate_to write Setdate_to;
  end;



  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse = class(TRemotable)
  private
    FvoucherTransactions: ArrayOfVoucherTransaction;
    function  GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
    procedure SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
  public
    constructor Create; override;
  published
    property voucherTransactions: ArrayOfVoucherTransaction  Index (IS_NLBL or IS_UNQL) read GetvoucherTransactions write SetvoucherTransactions;
  end;



  // ************************************************************************ //
  // XML       : VoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  VoucherTransaction = class(TRemotable)
  private
    FGLOBAL_SERIAL_NUMBER: string;
    FDATE_CREATED: string;
    FAMOUNT: string;
    FSTATUS: string;
    FPIN_CODE: string;
    FEXT_REF: string;
    FSTORE_ID: string;
    FTERMINAL_ID: string;
    FEMP_ID: string;
    FDATE_INVALIDATED: string;
    FEXPIRY_DATE: string;
    function  GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
    procedure SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
    function  GetDATE_CREATED(Index: Integer): string;
    procedure SetDATE_CREATED(Index: Integer; const Astring: string);
    function  GetAMOUNT(Index: Integer): string;
    procedure SetAMOUNT(Index: Integer; const Astring: string);
    function  GetSTATUS(Index: Integer): string;
    procedure SetSTATUS(Index: Integer; const Astring: string);
    function  GetPIN_CODE(Index: Integer): string;
    procedure SetPIN_CODE(Index: Integer; const Astring: string);
    function  GetEXT_REF(Index: Integer): string;
    procedure SetEXT_REF(Index: Integer; const Astring: string);
    function  GetSTORE_ID(Index: Integer): string;
    procedure SetSTORE_ID(Index: Integer; const Astring: string);
    function  GetTERMINAL_ID(Index: Integer): string;
    procedure SetTERMINAL_ID(Index: Integer; const Astring: string);
    function  GetEMP_ID(Index: Integer): string;
    procedure SetEMP_ID(Index: Integer; const Astring: string);
    function  GetDATE_INVALIDATED(Index: Integer): string;
    procedure SetDATE_INVALIDATED(Index: Integer; const Astring: string);
    function  GetEXPIRY_DATE(Index: Integer): string;
    procedure SetEXPIRY_DATE(Index: Integer; const Astring: string);
  published
    property GLOBAL_SERIAL_NUMBER: string  Index (IS_NLBL or IS_UNQL) read GetGLOBAL_SERIAL_NUMBER write SetGLOBAL_SERIAL_NUMBER;
    property DATE_CREATED:         string  Index (IS_NLBL or IS_UNQL) read GetDATE_CREATED write SetDATE_CREATED;
    property AMOUNT:               string  Index (IS_NLBL or IS_UNQL) read GetAMOUNT write SetAMOUNT;
    property STATUS:               string  Index (IS_NLBL or IS_UNQL) read GetSTATUS write SetSTATUS;
    property PIN_CODE:             string  Index (IS_NLBL or IS_UNQL) read GetPIN_CODE write SetPIN_CODE;
    property EXT_REF:              string  Index (IS_NLBL or IS_UNQL) read GetEXT_REF write SetEXT_REF;
    property STORE_ID:             string  Index (IS_NLBL or IS_UNQL) read GetSTORE_ID write SetSTORE_ID;
    property TERMINAL_ID:          string  Index (IS_NLBL or IS_UNQL) read GetTERMINAL_ID write SetTERMINAL_ID;
    property EMP_ID:               string  Index (IS_NLBL or IS_UNQL) read GetEMP_ID write SetEMP_ID;
    property DATE_INVALIDATED:     string  Index (IS_NLBL or IS_UNQL) read GetDATE_INVALIDATED write SetDATE_INVALIDATED;
    property EXPIRY_DATE:          string  Index (IS_NLBL or IS_UNQL) read GetEXPIRY_DATE write SetEXPIRY_DATE;
  end;



  // ************************************************************************ //
  // XML       : getTransactions, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactions2 = class(getTransactions)
  private
  published
  end;



  // ************************************************************************ //
  // XML       : getTransactionsResponse, global, <element>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // Info      : Wrapper
  // ************************************************************************ //
  getTransactionsResponse2 = class(getTransactionsResponse)
  private
  published
  end;

  Array_Of_VoucherTransaction = array of VoucherTransaction;   { "https://webmethods.someurl.com/TopUpServices/webServices/Voucher"[GblUbnd] }


  // ************************************************************************ //
  // XML       : ArrayOfVoucherTransaction, global, <complexType>
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // ************************************************************************ //
  ArrayOfVoucherTransaction = class(TRemotable)
  private
    FArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction;
    function  GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
    procedure SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
  public
    function   GetVoucherTransactionArray(Index: Integer): VoucherTransaction;       
    procedure  SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
    function   GetVoucherTransactionArrayLength: Integer;
    procedure  SetVoucherTransactionArrayLength(Len: Integer);

    property   VoucherTransactionArray[Index: Integer]: VoucherTransaction read GetVoucherTransactionArray write SetVoucherTransactionArray; default;
    property   Len: Integer read GetVoucherTransactionArrayLength write SetVoucherTransactionArrayLength;
  published
    property ArrayOfVoucherTransactionItem: Array_Of_VoucherTransaction  Index (IS_UNBD or IS_UNQL) read GetArrayOfVoucherTransactionItem write SetArrayOfVoucherTransactionItem;
  end;


  // ************************************************************************ //
  // Namespace : https://webmethods.someurl.com/TopUpServices/webServices/Voucher
  // soapAction: TopUpServices_webServices_Voucher_Binder_%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // binding   : TopUpServices_webServices_Voucher_Binder
  // service   : Voucher
  // port      : TopUpServices_webServices_Voucher_Port
  // URL       : https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher
  // ************************************************************************ //
  Voucher_PortType = interface(IInvokable)
  ['{DCE754E5-4B05-3C9B-8078-D4C2BB3F12B4}']

    // Cannot unwrap: 
    //     - Input element wrapper name does not match operation's name
    //     - More than one strictly out element was found
     function  getTransactions(const parameters: getTransactions2): getTransactionsResponse2; stdcall;

   end;

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


implementation
  uses SysUtils;

function GetVoucher_PortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): Voucher_PortType;
const
  defWSDL = 'https://webmethods.someurl.com/ws/TopUpServices.webServices:Voucher?WSDL';
  defURL  = 'https://webmethods.someurl.com:443/ws/TopUpServices.webServices:Voucher';
  defSvc  = 'Voucher';
  defPrt  = 'TopUpServices_webServices_Voucher_Port';
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 Voucher_PortType);
    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;


constructor getTransactions.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactions.Getdate_from(Index: Integer): string;
begin
  Result := Fdate_from;
end;

procedure getTransactions.Setdate_from(Index: Integer; const Astring: string);
begin
  Fdate_from := Astring;
end;

function getTransactions.Getdate_to(Index: Integer): string;
begin
  Result := Fdate_to;
end;

procedure getTransactions.Setdate_to(Index: Integer; const Astring: string);
begin
  Fdate_to := Astring;
end;

constructor getTransactionsResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

function getTransactionsResponse.GetvoucherTransactions(Index: Integer): ArrayOfVoucherTransaction;
begin
  Result := FvoucherTransactions;
end;

procedure getTransactionsResponse.SetvoucherTransactions(Index: Integer; const AArrayOfVoucherTransaction: ArrayOfVoucherTransaction);
begin
  FvoucherTransactions := AArrayOfVoucherTransaction;
end;

function VoucherTransaction.GetGLOBAL_SERIAL_NUMBER(Index: Integer): string;
begin
  Result := FGLOBAL_SERIAL_NUMBER;
end;

procedure VoucherTransaction.SetGLOBAL_SERIAL_NUMBER(Index: Integer; const Astring: string);
begin
  FGLOBAL_SERIAL_NUMBER := Astring;
end;

function VoucherTransaction.GetDATE_CREATED(Index: Integer): string;
begin
  Result := FDATE_CREATED;
end;

procedure VoucherTransaction.SetDATE_CREATED(Index: Integer; const Astring: string);
begin
  FDATE_CREATED := Astring;
end;

function VoucherTransaction.GetAMOUNT(Index: Integer): string;
begin
  Result := FAMOUNT;
end;

procedure VoucherTransaction.SetAMOUNT(Index: Integer; const Astring: string);
begin
  FAMOUNT := Astring;
end;

function VoucherTransaction.GetSTATUS(Index: Integer): string;
begin
  Result := FSTATUS;
end;

procedure VoucherTransaction.SetSTATUS(Index: Integer; const Astring: string);
begin
  FSTATUS := Astring;
end;

function VoucherTransaction.GetPIN_CODE(Index: Integer): string;
begin
  Result := FPIN_CODE;
end;

procedure VoucherTransaction.SetPIN_CODE(Index: Integer; const Astring: string);
begin
  FPIN_CODE := Astring;
end;

function VoucherTransaction.GetEXT_REF(Index: Integer): string;
begin
  Result := FEXT_REF;
end;

procedure VoucherTransaction.SetEXT_REF(Index: Integer; const Astring: string);
begin
  FEXT_REF := Astring;
end;

function VoucherTransaction.GetSTORE_ID(Index: Integer): string;
begin
  Result := FSTORE_ID;
end;

procedure VoucherTransaction.SetSTORE_ID(Index: Integer; const Astring: string);
begin
  FSTORE_ID := Astring;
end;

function VoucherTransaction.GetTERMINAL_ID(Index: Integer): string;
begin
  Result := FTERMINAL_ID;
end;

procedure VoucherTransaction.SetTERMINAL_ID(Index: Integer; const Astring: string);
begin
  FTERMINAL_ID := Astring;
end;

function VoucherTransaction.GetEMP_ID(Index: Integer): string;
begin
  Result := FEMP_ID;
end;

procedure VoucherTransaction.SetEMP_ID(Index: Integer; const Astring: string);
begin
  FEMP_ID := Astring;
end;

function VoucherTransaction.GetDATE_INVALIDATED(Index: Integer): string;
begin
  Result := FDATE_INVALIDATED;
end;

procedure VoucherTransaction.SetDATE_INVALIDATED(Index: Integer; const Astring: string);
begin
  FDATE_INVALIDATED := Astring;
end;

function VoucherTransaction.GetEXPIRY_DATE(Index: Integer): string;
begin
  Result := FEXPIRY_DATE;
end;

procedure VoucherTransaction.SetEXPIRY_DATE(Index: Integer; const Astring: string);
begin
  FEXPIRY_DATE := Astring;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArray(Index: Integer): VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem[Index];
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArray(Index: Integer; const Item: VoucherTransaction);
begin
   FArrayOfVoucherTransactionItem[Index] := Item;
end;

function ArrayOfVoucherTransaction.GetVoucherTransactionArrayLength: Integer;
begin
  if Assigned(FArrayOfVoucherTransactionItem) then
    Result := System.Length(FArrayOfVoucherTransactionItem)
  else
    Result := 0;
end;

procedure ArrayOfVoucherTransaction.SetVoucherTransactionArrayLength(Len: Integer);
begin
  System.SetLength(FArrayOfVoucherTransactionItem, Len);
end;

function ArrayOfVoucherTransaction.GetArrayOfVoucherTransactionItem(Index: Integer): Array_Of_VoucherTransaction;
begin
  Result := FArrayOfVoucherTransactionItem;
end;

procedure ArrayOfVoucherTransaction.SetArrayOfVoucherTransactionItem(Index: Integer; const AArray_Of_VoucherTransaction: Array_Of_VoucherTransaction);
begin
  FArrayOfVoucherTransactionItem := AArray_Of_VoucherTransaction;
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(Voucher_PortType), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Voucher_PortType), 'TopUpServices_webServices_Voucher_Binder_%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioLiteral);
  InvRegistry.RegisterInvokeOptions(TypeInfo(Voucher_PortType), ioSOAP12);
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'invalidateVoucher', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'getTransactions', 'parameters1', 'parameters');
  InvRegistry.RegisterExternalParamName(TypeInfo(Voucher_PortType), 'createVoucher', 'parameters1', 'parameters');
  RemClassRegistry.RegisterXSClass(getTransactions, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions');
  RemClassRegistry.RegisterSerializeOptions(getTransactions, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(getTransactionsResponse, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse');
  RemClassRegistry.RegisterSerializeOptions(getTransactionsResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(VoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'VoucherTransaction');
  RemClassRegistry.RegisterXSClass(getTransactions2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactions2', 'getTransactions');
  RemClassRegistry.RegisterXSClass(getTransactionsResponse2, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'getTransactionsResponse2', 'getTransactionsResponse');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_VoucherTransaction), 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'Array_Of_VoucherTransaction');
  RemClassRegistry.RegisterXSClass(ArrayOfVoucherTransaction, 'https://webmethods.someurl.com/TopUpServices/webServices/Voucher', 'ArrayOfVoucherTransaction');

end.


Use SoapUI to consume the WSDL and create a mockservice. Point your app at the SoapUI mockservice, and you'll see what your XML looks like (SoapUI will capture your request).

Now run SoapUI against the original endpoint (let SoapUI create a sample request) and see if that works. If it does, "stare and compare" the SoapUI request against yours.

Alternately, use the RIO events to intercept the XML after serialization, and dump to a text file. Now you can see the resulting XML. Again, I'd recommend pasting that into SoapUI and sending it to the endpoint, to see if it works there. I suspect it won't, and by comparing a working request against your request, you may see what's wrong. Bad date format, bad method name, missing namespaces, etc...

Upon successful completion, your "getrr" variable should hold the response object. You will likely need to traverse down through the response object, iterating through the arrays of vouchers, transactions, and gobbledy-gook. Delphi's debuger will help here - set a breakpoint after the service call, and you can inspect the response. You may need to add some code so that the call isn't the last thing in your procedure, or the compiler may eliminate it. i.e. you're not currently doing ANYTHING with the response object.


Although I don't particular like the MapArraysToClasses option enabled, the following illustrates how to access the data sent back by the service with the proxy you've generated:

procedure TForm33.Button1Click(Sender: TObject);
var
  rr     : voucher17.getTransactions2;
  getrr    : voucher17.getTransactionsResponse2;
  I: Integer;
begin
  rr := getTransactions2.Create;
  try
    rr.date_from := '09.01.2011';
    rr.date_to   := '10.01.2011';

    getrr := GetVoucher_PortType.getTransactions(rr);
    try
      if Assigned(getrr.voucherTransactions) then
      begin
        for I := 0 to getrr.voucherTransactions.Len-1 do
        begin
          ShowMessage(Format('%s, %s, %s', [
              getrr.voucherTransactions[I].GLOBAL_SERIAL_NUMBER,
              getrr.voucherTransactions[I].DATE_CREATED,
              getrr.voucherTransactions[I].AMOUNT]));
        end;
      end;
    finally
      getrr.Free;
    end;
  finally
    rr.Free;
  end;
end;

I'm opting to display the values of three of the fields. You'll probably want to read the other fields as well.

I don't like the fact that AutoDestroyMembers was disabled because even though the code above cleans up the request and response objects, the array of objects contained in the response will not be cleaned up properly:(.

Cheers,

Bruneau

0

精彩评论

暂无评论...
验证码 换一张
取 消