Я пытаюсь использовать webserivce с Delphi 2010, но не могу заставить gettransaction работать правильно.Как я могу использовать Delphi, чтобы получить ответ от этой функции?Я могу вставить параметр, чтобы вызвать его, но не получить ответ.
Как я могу использовать Delphi или c # для чтения ответа?
Это 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" type="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"/>
Я вызываю webserive с gettransaction с параметром С 01.01.2011 и по 17.01.2011
Эта функция выглядит как в 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;
Это возврат из soapui, так что это работает, но как можно использовать delphi для чтения из этого?
<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>
Вотпрокси
// ************************************************************************ //
// 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.