Einzelnen Beitrag anzeigen

af99

Registriert seit: 22. Apr 2004
84 Beiträge
 
Delphi XE5 Ultimate
 
#1

Webservice Rückgabe komplexe Datenstruktur

  Alt 7. Jun 2011, 15:37
Hallo Zusammen,

ich versuche verzweifelt eine Antwort von einem Webservice zu erhalten leider scheitert scheinbar schon der Aufruf an der Datenstruktur.
Ich arbeite mit Delphi XE und habe die WSDL Datei mit dem Assistenten importiert.
Hier der Aufruf
Code:
procedure TForm4.BitBtn1Click(Sender: TObject);
var
  gi: messageout;
  rein: messagein;
  myArray : array[0..1] of ItemType;
  myItemType : ItemType;

begin
  gi := messageout.Create;
  rein := messagein.Create;

  myItemType := ItemType.Create;
  myItemType.Article := '10000100';
  myItemType.Quantity := 1;

  myArray[0] := myItemType;

  rein.CustomerNo := 1;
  rein.Item[0] := myItemType;

  gi := (soe as web_getInventory).getInventory(rein);
  showmessage(inttostr(gi.Inventory.Item.Quantity));
  rein.Destroy;
  gi.Destroy;
end;
Hier die WSDL Datei
Code:
unit web;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

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


type
ItemTypeOut         = class;                  MessageIn           = class;                  ItemType            = class;                  InventoryType       = class;                  MessageOut          = class;                
Array_Of_ItemType = array of ItemType;
ItemTypeOut = class(TRemotable)
  private
    FArticle: string;
    FQuantity: Integer;
    FAvailabilityState: string;
    FAvailabilityQuantity: Integer;
    FAvailabilityQuantity_Specified: boolean;
    FAvailabiltyText: string;
    FAvailabiltyText_Specified: boolean;
    FArticleDescription_1: string;
    FArticleDescription_1_Specified: boolean;
    FArticleDescription_2: string;
    FArticleDescription_2_Specified: boolean;
    FArticleState: Integer;
    FArticleState_Specified: boolean;
    FArticleStateText: string;
    FArticleStateText_Specified: boolean;
    procedure SetAvailabilityQuantity(Index: Integer; const AInteger: Integer);
    function AvailabilityQuantity_Specified(Index: Integer): boolean;
    procedure SetAvailabiltyText(Index: Integer; const Astring: string);
    function AvailabiltyText_Specified(Index: Integer): boolean;
    procedure SetArticleDescription_1(Index: Integer; const Astring: string);
    function ArticleDescription_1_Specified(Index: Integer): boolean;
    procedure SetArticleDescription_2(Index: Integer; const Astring: string);
    function ArticleDescription_2_Specified(Index: Integer): boolean;
    procedure SetArticleState(Index: Integer; const AInteger: Integer);
    function ArticleState_Specified(Index: Integer): boolean;
    procedure SetArticleStateText(Index: Integer; const Astring: string);
    function ArticleStateText_Specified(Index: Integer): boolean;
  published
    property Article:             string  Index (IS_UNQL) read FArticle write FArticle;
    property Quantity:            Integer Index (IS_UNQL) read FQuantity write FQuantity;
    property AvailabilityState:   string  Index (IS_UNQL) read FAvailabilityState write FAvailabilityState;
    property AvailabilityQuantity: Integer Index (IS_OPTN or IS_UNQL) read FAvailabilityQuantity write SetAvailabilityQuantity stored AvailabilityQuantity_Specified;
    property AvailabiltyText:     string  Index (IS_OPTN or IS_UNQL) read FAvailabiltyText write SetAvailabiltyText stored AvailabiltyText_Specified;
    property ArticleDescription_1: string  Index (IS_OPTN or IS_UNQL) read FArticleDescription_1 write SetArticleDescription_1 stored ArticleDescription_1_Specified;
    property ArticleDescription_2: string  Index (IS_OPTN or IS_UNQL) read FArticleDescription_2 write SetArticleDescription_2 stored ArticleDescription_2_Specified;
    property ArticleState:        Integer Index (IS_OPTN or IS_UNQL) read FArticleState write SetArticleState stored ArticleState_Specified;
    property ArticleStateText:    string  Index (IS_OPTN or IS_UNQL) read FArticleStateText write SetArticleStateText stored ArticleStateText_Specified;
  end;
  MessageIn = class(TRemotable)
  private
    FCustomerNo: Integer;
    FItem: Array_Of_ItemType;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property CustomerNo: Integer           Index (IS_UNQL) read FCustomerNo write FCustomerNo;
    property Item:      Array_Of_ItemType Index (IS_UNBD or IS_UNQL) read FItem write FItem;
  end;
  ItemType = class(TRemotable)
  private
    FArticle: string;
    FQuantity: Integer;
  published
    property Article: string  Index (IS_UNQL) read FArticle write FArticle;
    property Quantity: Integer Index (IS_UNQL) read FQuantity write FQuantity;
  end;

  InventoryType = class(TRemotable)
  private
    FCustomerNo: Integer;
    FItem: ItemTypeOut;
  public
    destructor Destroy; override;
  published
    property CustomerNo: Integer     Index (IS_UNQL) read FCustomerNo write FCustomerNo;
    property Item:      ItemTypeOut Index (IS_UNQL) read FItem write FItem;
  end;
  MessageOut = class(TRemotable)
  private
    FInventory: InventoryType;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Inventory: InventoryType Index (IS_UNQL) read FInventory write FInventory;
  end;
 web_getInventory = interface(IInvokable)
  ['{7ECC6115-0305-FA86-1773-54264E557E44}']

    // Entpacken nicht möglich:
    //     - Eingabe-Part verweist auf kein Element
    //     - Ausgabe-Part verweist auf kein Element
    function getInventory(const getInventoryIn: MessageIn): MessageOut; stdcall;
  end;

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


implementation
  uses SysUtils;
...
Wenn ich das Programm nun schrittweise ausführe Taste "F8" dann springt die Ausführung komischerweise immer von der Programmzeile
rein.Item[0] := myItemType;
zur Programmzeile
end;
der Procedure procedure TForm4.BitBtn1Click(Sender: TObject); (siehe Source1) ohne die Programmzeilen dazwischen auszuführen. Auf dem End; kommt dann eine Exception.

Was mache ich falsch ???
  Mit Zitat antworten Zitat