![]() |
WSDL Import - ist die Nutzung richtig
Bank BLZ Service (Bank Sort Codes): This WSDL generates request and response for a web service using which you can fetch Bank Sort Codes (called Bank BLZ codes) for banks in Germany.
In the request, you need to pass the BLZ code for any bank in Germany and it comes back with the bank details. You can get plenty of Bank BLZ codes at blzcodes.com. ![]() Ich habe diese URL " ![]() Die automatisch generierte Datei sieht dann wie folgt aus:
Delphi-Quellcode:
Form mit Button & Memo Feld, BLZService per uses hinzugefügt. Der Aufruf erfolgt über:
// ************************************************************************ //
// Die in dieser Datei deklarierten Typen wurden aus Daten der unten // beschriebenen WSDL-Datei generiert: // WSDL : http://www.thomas-bayer.com/axis2/services/BLZService?wsdl // >Import : http://www.thomas-bayer.com/axis2/services/BLZService?wsdl>0 // Version: 1.0 // (17.01.2017 12:09:09 - - $Rev: 45757 $) // ************************************************************************ // unit BLZService; interface uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns; const IS_OPTN = $0001; type // ************************************************************************ // // Die folgenden Typen, auf die im WSDL-Dokument Bezug genommen wird, sind in dieser Datei // nicht repräsentiert. Sie sind entweder Aliase[@] anderer repräsentierter Typen oder auf sie wurde Bezug genommen, // aber sie sind in diesem Dokument nicht[!] deklariert. Die Typen aus letzterer Kategorie // sind in der Regel vordefinierten/bekannten XML- oder Embarcadero-Typen zugeordnet; sie könnten aber auf // ein inkorrektes WSDL-Dokument hinweisen, das einen Schematyp nicht deklariert oder importiert hat. // ************************************************************************ // // !:string - "http://www.w3.org/2001/XMLSchema"[Gbl] detailsType = class; { "http://thomas-bayer.com/blz/"[GblCplx] } // ************************************************************************ // // XML : detailsType, global, <complexType> // Namespace : http://thomas-bayer.com/blz/ // ************************************************************************ // detailsType = class(TRemotable) private Fbezeichnung: string; Fbezeichnung_Specified: boolean; Fbic: string; Fbic_Specified: boolean; Fort: string; Fort_Specified: boolean; Fplz: string; Fplz_Specified: boolean; procedure Setbezeichnung(Index: Integer; const Astring: string); function bezeichnung_Specified(Index: Integer): boolean; procedure Setbic(Index: Integer; const Astring: string); function bic_Specified(Index: Integer): boolean; procedure Setort(Index: Integer; const Astring: string); function ort_Specified(Index: Integer): boolean; procedure Setplz(Index: Integer; const Astring: string); function plz_Specified(Index: Integer): boolean; published property bezeichnung: string Index (IS_OPTN) read Fbezeichnung write Setbezeichnung stored bezeichnung_Specified; property bic: string Index (IS_OPTN) read Fbic write Setbic stored bic_Specified; property ort: string Index (IS_OPTN) read Fort write Setort stored ort_Specified; property plz: string Index (IS_OPTN) read Fplz write Setplz stored plz_Specified; end; // ************************************************************************ // // Namespace : http://thomas-bayer.com/blz/ // Transport : http://schemas.xmlsoap.org/soap/http // Stil : document // Verwenden von : literal // Bindung : BLZServiceSOAP12Binding // Service : BLZService // Port : BLZServiceSOAP12port_http // URL : http://www.thomas-bayer.com/axis2/services/BLZService // ************************************************************************ // BLZServicePortType = interface(IInvokable) ['{83022A17-51E1-867E-FE61-73762B29E2EA}'] function getBank(const blz: string): detailsType; stdcall; end; function GetBLZServicePortType(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): BLZServicePortType; implementation uses SysUtils; function GetBLZServicePortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): BLZServicePortType; const defWSDL = 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl'; defURL = 'http://www.thomas-bayer.com/axis2/services/BLZService'; defSvc = 'BLZService'; defPrt = 'BLZServiceSOAP12port_http'; 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 BLZServicePortType); 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; procedure detailsType.Setbezeichnung(Index: Integer; const Astring: string); begin Fbezeichnung := Astring; Fbezeichnung_Specified := True; end; function detailsType.bezeichnung_Specified(Index: Integer): boolean; begin Result := Fbezeichnung_Specified; end; procedure detailsType.Setbic(Index: Integer; const Astring: string); begin Fbic := Astring; Fbic_Specified := True; end; function detailsType.bic_Specified(Index: Integer): boolean; begin Result := Fbic_Specified; end; procedure detailsType.Setort(Index: Integer; const Astring: string); begin Fort := Astring; Fort_Specified := True; end; function detailsType.ort_Specified(Index: Integer): boolean; begin Result := Fort_Specified; end; procedure detailsType.Setplz(Index: Integer; const Astring: string); begin Fplz := Astring; Fplz_Specified := True; end; function detailsType.plz_Specified(Index: Integer): boolean; begin Result := Fplz_Specified; end; initialization { BLZServicePortType } InvRegistry.RegisterInterface(TypeInfo(BLZServicePortType), 'http://thomas-bayer.com/blz/', ''); InvRegistry.RegisterDefaultSOAPAction(TypeInfo(BLZServicePortType), ''); InvRegistry.RegisterInvokeOptions(TypeInfo(BLZServicePortType), ioDocument); InvRegistry.RegisterInvokeOptions(TypeInfo(BLZServicePortType), ioSOAP12); { BLZServicePortType.getBank } InvRegistry.RegisterMethodInfo(TypeInfo(BLZServicePortType), 'getBank', '', '[ReturnName="details"]'); RemClassRegistry.RegisterXSClass(detailsType, 'http://thomas-bayer.com/blz/', 'detailsType'); end.
Delphi-Quellcode:
Im Memo ist dann folgendes Ergebnis:
procedure TForm1.Button1Click(Sender: TObject);
var erg: detailsType; begin erg := detailsType.Create; try erg := GetBLZServicePortType(true).getBank('50010517'); Memo1.Lines.Append(erg.bezeichnung); Memo1.Lines.Append(erg.bic); Memo1.Lines.Append(erg.ort); Memo1.Lines.Append(erg.plz); finally erg.Free; end; end;
Code:
Frage 1: Mache ich das richtig so, meine den Aufruf?
ING-DiBa
INGDDEFFXXX Frankfurt am Main 60628 Frage 2: Setze ich bei obigem Code "ReportMemoryLeaksOnShutdown := True;" so erhalte ich beim Beenden der Anwendung nachfolgende Meldung, warum ?
Code:
---------------------------
Unexpected Memory Leak --------------------------- An unexpected memory leak has occurred. The unexpected small block leaks are: 45 - 52 bytes: detailsType x 2 --------------------------- OK --------------------------- |
AW: WSDL Import - ist die Nutzung richtig
Du musst Dein erg nicht selber erzeugen
das wird schon in getBank Erledigt. Mach es so:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var erg: detailsType; begin // erg := detailsType.Create; erg := GetBLZServicePortType(true).getBank('50010517'); if assigned(erg) then try Memo1.Lines.Append(erg.bezeichnung); Memo1.Lines.Append(erg.bic); Memo1.Lines.Append(erg.ort); Memo1.Lines.Append(erg.plz); finally erg.Free; end; end; |
AW: WSDL Import - ist die Nutzung richtig
Du erzeugst die Instanz selbst und überschreibst Deine Instanzvariable im Anschluss mit der, die aus dem Interface kommt.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz