Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Rückgabe von Daten aus einem Webservice

  Alt 14. Dez 2010, 12:05
Die benötigten Strukturen stehen in der WDSL-Beschreibung.

Am einfachsten wäre es, den WDSL-Importer von Delphi zu benutzen - aber ob Delphi 5 den schon hat?

So sieht das mit Delphi 2010 aus (allerdings finde ich hier keine komplexen Datenstrukturen):
Delphi-Quellcode:
// ************************************************************************ //
// Die in dieser Datei deklarierten Typen wurden aus Daten der unten
// beschriebenen WSDL-Datei generiert:

// WSDL : http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx?WSDL
// >Import : http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx?WSDL>0
// Codierung : utf-8
// Version: 1.0
// (14.12.2010 12:01:55 - - $Rev: 25127 $)
// ************************************************************************ //

unit USHolidayDates;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_REF = $0080;


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.
  // ************************************************************************ //
  // !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:dateTime - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:string - "http://www.w3.org/2001/XMLSchema"[]


  dateTime = class(TXSDateTime) end; { "http://www.27seconds.com/Holidays/US/Dates/"[GblElm] }

  // ************************************************************************ //
  // Namespace : http://www.27seconds.com/Holidays/US/Dates/
  // soapAction: http://www.27seconds.com/Holidays/US/Dates/%operationName%
  // Transport : http://schemas.xmlsoap.org/soap/http
  // Stil : document
  // Bindung : USHolidayDatesSoap
  // Service : USHolidayDates
  // Port : USHolidayDatesSoap
  // URL : http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx
  // ************************************************************************ //
  USHolidayDatesSoap = interface(IInvokable)
  ['{B6CD6BA8-97F2-BB71-B66E-69187A32861C}']
    function GetNewYear(const year: Integer): TXSDateTime; stdcall;
    function GetMartinLutherKingDay(const year: Integer): TXSDateTime; stdcall;
    function GetPresidentsDay(const year: Integer): TXSDateTime; stdcall;
    function GetAbrahamLincolnsBirthday(const year: Integer): TXSDateTime; stdcall;
    function GetValentinesDay(const year: Integer): TXSDateTime; stdcall;
    function GetGeorgeWashingtonsBirthday(const year: Integer): TXSDateTime; stdcall;
    function GetGoodFriday(const year: Integer): TXSDateTime; stdcall;
    function GetEaster(const year: Integer): TXSDateTime; stdcall;
    function GetSaintPatricksDay(const year: Integer): TXSDateTime; stdcall;
    function GetAprilFoolsDay(const year: Integer): TXSDateTime; stdcall;
    function GetMothersDay(const year: Integer): TXSDateTime; stdcall;
    function GetMemorialDay(const year: Integer): TXSDateTime; stdcall;
    function GetCincoDeMayo(const year: Integer): TXSDateTime; stdcall;
    function GetFathersDay(const year: Integer): TXSDateTime; stdcall;
    function GetFlagDay(const year: Integer): TXSDateTime; stdcall;
    function GetIndependenceDay(const year: Integer): TXSDateTime; stdcall;
    function GetLaborDay(const year: Integer): TXSDateTime; stdcall;
    function GetColumbusDay(const year: Integer): TXSDateTime; stdcall;
    function GetHalloweenDay(const year: Integer): TXSDateTime; stdcall;
    function GetThanksgivingDay(const year: Integer): TXSDateTime; stdcall;
    function GetBlackFriday(const year: Integer): TXSDateTime; stdcall;
    function GetVeteransDay(const year: Integer): TXSDateTime; stdcall;
    function GetChristmasDay(const year: Integer): TXSDateTime; stdcall;
    function GetNewYearsEve(const year: Integer): TXSDateTime; stdcall;
  end;


  // ************************************************************************ //
  // Namespace : http://www.27seconds.com/Holidays/US/Dates/
  // Bindung : USHolidayDatesHttpGet
  // Service : USHolidayDates
  // Port : USHolidayDatesHttpGet
  // ************************************************************************ //
  USHolidayDatesHttpGet = interface(IInvokable)
  ['{38B1DA29-A668-F33D-9DDA-49B235C31176}']
    function GetNewYear(const year: string): dateTime; stdcall;
    function GetMartinLutherKingDay(const year: string): dateTime; stdcall;
    function GetPresidentsDay(const year: string): dateTime; stdcall;
    function GetAbrahamLincolnsBirthday(const year: string): dateTime; stdcall;
    function GetValentinesDay(const year: string): dateTime; stdcall;
    function GetGeorgeWashingtonsBirthday(const year: string): dateTime; stdcall;
    function GetGoodFriday(const year: string): dateTime; stdcall;
    function GetEaster(const year: string): dateTime; stdcall;
    function GetSaintPatricksDay(const year: string): dateTime; stdcall;
    function GetAprilFoolsDay(const year: string): dateTime; stdcall;
    function GetMothersDay(const year: string): dateTime; stdcall;
    function GetMemorialDay(const year: string): dateTime; stdcall;
    function GetCincoDeMayo(const year: string): dateTime; stdcall;
    function GetFathersDay(const year: string): dateTime; stdcall;
    function GetFlagDay(const year: string): dateTime; stdcall;
    function GetIndependenceDay(const year: string): dateTime; stdcall;
    function GetLaborDay(const year: string): dateTime; stdcall;
    function GetColumbusDay(const year: string): dateTime; stdcall;
    function GetHalloweenDay(const year: string): dateTime; stdcall;
    function GetThanksgivingDay(const year: string): dateTime; stdcall;
    function GetBlackFriday(const year: string): dateTime; stdcall;
    function GetVeteransDay(const year: string): dateTime; stdcall;
    function GetChristmasDay(const year: string): dateTime; stdcall;
    function GetNewYearsEve(const year: string): dateTime; stdcall;
  end;


  // ************************************************************************ //
  // Namespace : http://www.27seconds.com/Holidays/US/Dates/
  // Bindung : USHolidayDatesHttpPost
  // Service : USHolidayDates
  // Port : USHolidayDatesHttpPost
  // ************************************************************************ //
  USHolidayDatesHttpPost = interface(IInvokable)
  ['{F85448EA-3AD3-4D27-EE8F-B6A99FC21C12}']
    function GetNewYear(const year: string): dateTime; stdcall;
    function GetMartinLutherKingDay(const year: string): dateTime; stdcall;
    function GetPresidentsDay(const year: string): dateTime; stdcall;
    function GetAbrahamLincolnsBirthday(const year: string): dateTime; stdcall;
    function GetValentinesDay(const year: string): dateTime; stdcall;
    function GetGeorgeWashingtonsBirthday(const year: string): dateTime; stdcall;
    function GetGoodFriday(const year: string): dateTime; stdcall;
    function GetEaster(const year: string): dateTime; stdcall;
    function GetSaintPatricksDay(const year: string): dateTime; stdcall;
    function GetAprilFoolsDay(const year: string): dateTime; stdcall;
    function GetMothersDay(const year: string): dateTime; stdcall;
    function GetMemorialDay(const year: string): dateTime; stdcall;
    function GetCincoDeMayo(const year: string): dateTime; stdcall;
    function GetFathersDay(const year: string): dateTime; stdcall;
    function GetFlagDay(const year: string): dateTime; stdcall;
    function GetIndependenceDay(const year: string): dateTime; stdcall;
    function GetLaborDay(const year: string): dateTime; stdcall;
    function GetColumbusDay(const year: string): dateTime; stdcall;
    function GetHalloweenDay(const year: string): dateTime; stdcall;
    function GetThanksgivingDay(const year: string): dateTime; stdcall;
    function GetBlackFriday(const year: string): dateTime; stdcall;
    function GetVeteransDay(const year: string): dateTime; stdcall;
    function GetChristmasDay(const year: string): dateTime; stdcall;
    function GetNewYearsEve(const year: string): dateTime; stdcall;
  end;

function GetUSHolidayDatesSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): USHolidayDatesSoap;
function GetUSHolidayDatesHttpGet(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): USHolidayDatesHttpGet;
function GetUSHolidayDatesHttpPost(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): USHolidayDatesHttpPost;


implementation
  uses SysUtils;

function GetUSHolidayDatesSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): USHolidayDatesSoap;
const
  defWSDL = 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx?WSDL';
  defURL = 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx';
  defSvc = 'USHolidayDates';
  defPrt = 'USHolidayDatesSoap';
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 USHolidayDatesSoap);
    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;


function GetUSHolidayDatesHttpGet(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): USHolidayDatesHttpGet;
const
  defWSDL = 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx?WSDL';
  defURL = '';
  defSvc = 'USHolidayDates';
  defPrt = 'USHolidayDatesHttpGet';
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 USHolidayDatesHttpGet);
    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;


function GetUSHolidayDatesHttpPost(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): USHolidayDatesHttpPost;
const
  defWSDL = 'http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx?WSDL';
  defURL = '';
  defSvc = 'USHolidayDates';
  defPrt = 'USHolidayDatesHttpPost';
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 USHolidayDatesHttpPost);
    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;


initialization
  InvRegistry.RegisterInterface(TypeInfo(USHolidayDatesSoap), 'http://www.27seconds.com/Holidays/US/Dates/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(USHolidayDatesSoap), 'http://www.27seconds.com/Holidays/US/Dates/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(USHolidayDatesSoap), ioDocument);
  InvRegistry.RegisterInterface(TypeInfo(USHolidayDatesHttpGet), 'http://www.27seconds.com/Holidays/US/Dates/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(USHolidayDatesHttpGet), '');
  InvRegistry.RegisterInterface(TypeInfo(USHolidayDatesHttpPost), 'http://www.27seconds.com/Holidays/US/Dates/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(USHolidayDatesHttpPost), '');
  RemClassRegistry.RegisterXSInfo(TypeInfo(dateTime), 'http://www.27seconds.com/Holidays/US/Dates/', 'dateTime');

end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat