Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Problem beim SOAP Abruf (https://www.delphipraxis.net/203118-problem-beim-soap-abruf.html)

Blackpit 15. Jan 2020 14:03

Problem beim SOAP Abruf
 
Hallo,
ich hab hier ein Problem das ich mir nicht erklären kann.
Beim Abruf eines Webservice über das importierte WSDL bekomme ich folgende Meldung:
Zitat:

'Die Anforderung konnte vom Server nicht verarbeitet werden. ---> Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.'
Interface (Auszug):

Delphi-Quellcode:
// ************************************************************************ //
// Die in dieser Datei deklarierten Typen wurden aus Daten der unten
// beschriebenen WSDL-Datei generiert:

// WSDL    : https://...de/services/api/salesservice.asmx?WSDL
//  >Import : https://...de/services/api/salesservice.asmx?WSDL>0
// Codierung : utf-8
// Codegen : [wfForceSOAP12+]
// Version: 1.0
// (13.01.2020 15:14:48 - - $Rev: 76228 $)
// ************************************************************************ //

unit salesservice;

interface

uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;

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

  DealerInformationModel = class;              { "http://www.servadr.de/"[GblCplx] }
  WebLogin2         = class;                   { "http://www.servadr.de/"[Hdr][GblCplx] }
  WebLogin         = class;                   { "http://www.servadr.de/"[Hdr][GblElm] }
  CompleteVehicleInformationModel = class;     { "http://www.servadr.de/"[GblCplx] }
  PaymentConditionModel = class;               { "http://www.servadr.de/"[GblCplx] }
  EquipmentModel      = class;                { "http://www.servadr.de/"[GblCplx] }

...
  // ************************************************************************ //
  // XML      : WebLogin, global, <complexType>
  // Namespace : http://www.servadr.de/
  // Info     : Header
  // ************************************************************************ //
  WebLogin2 = class(TSOAPHeader)
  private
    FUser: string;
    FUser_Specified: boolean;
    FPassword: string;
    FPassword_Specified: boolean;
    FLanguage: Integer;
    procedure SetUser(Index: Integer; const Astring: string);
    function User_Specified(Index: Integer): boolean;
    procedure SetPassword(Index: Integer; const Astring: string);
    function Password_Specified(Index: Integer): boolean;
  published
    property User:    string  Index (IS_OPTN) read FUser write SetUser stored User_Specified;
    property Password: string  Index (IS_OPTN) read FPassword write SetPassword stored Password_Specified;
    property Language: Integer read FLanguage write FLanguage;
  end;



  // ************************************************************************ //
  // XML      : WebLogin, global, <element>
  // Namespace : http://www.web-kat.de/
  // Info     : Header
  // ************************************************************************ //
  WebLogin = class(WebLogin2)
  private
  published
  end;

  ArrayOfEquipmentModel = array of EquipmentModel;  { "http://www.servadr.de/"[GblCplx] }
...

  // ************************************************************************ //
  // XML      : CompleteVehicleInformationModel, global, <complexType>
  // Namespace : http://www.servadr.de/
  // ************************************************************************ //
  CompleteVehicleInformationModel = class(TRemotable)
  private
    FDealerInformation: DealerInformationModel;
    FDealerInformation_Specified: boolean;
    FEquipment: ArrayOfEquipmentModel;
    FEquipment_Specified: boolean;
    FPaymentConditions: ArrayOfPaymentConditionModel;
    FPaymentConditions_Specified: boolean;
    procedure SetDealerInformation(Index: Integer; const ADealerInformationModel: DealerInformationModel);
    function DealerInformation_Specified(Index: Integer): boolean;
    procedure SetEquipment(Index: Integer; const AArrayOfEquipmentModel: ArrayOfEquipmentModel);
    function Equipment_Specified(Index: Integer): boolean;
    procedure SetPaymentConditions(Index: Integer; const AArrayOfPaymentConditionModel: ArrayOfPaymentConditionModel);
    function PaymentConditions_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property DealerInformation: DealerInformationModel       Index (IS_OPTN) read FDealerInformation write SetDealerInformation stored DealerInformation_Specified;
    property Equipment:        ArrayOfEquipmentModel        Index (IS_OPTN) read FEquipment write SetEquipment stored Equipment_Specified;
    property PaymentConditions: ArrayOfPaymentConditionModel Index (IS_OPTN) read FPaymentConditions write SetPaymentConditions stored PaymentConditions_Specified;
  end;
...
  // ************************************************************************ //
  // XML      : EquipmentModel, global, <complexType>
  // Namespace : http://www.servadr.de/
  // ************************************************************************ //
  EquipmentModel = class(TRemotable)
  private
    FOrderPos: string;
    FOrderPos_Specified: boolean;
    FCondition: string;
    FCondition_Specified: boolean;
    FDescription: string;
    FDescription_Specified: boolean;
    FVarcond: string;
    FVarcond_Specified: boolean;
    FAmount: string;
    FAmount_Specified: boolean;
    FQuantity: TXSDecimal;
    FUnit_: string;
    FUnit__Specified: boolean;
    FTotalAmount: string;
    FTotalAmount_Specified: boolean;
    FCurrency: string;
    FCurrency_Specified: boolean;
    FListPrice: TXSDecimal;
    procedure SetOrderPos(Index: Integer; const Astring: string);
    function OrderPos_Specified(Index: Integer): boolean;
    procedure SetCondition(Index: Integer; const Astring: string);
    function Condition_Specified(Index: Integer): boolean;
    procedure SetDescription(Index: Integer; const Astring: string);
    function Description_Specified(Index: Integer): boolean;
    procedure SetVarcond(Index: Integer; const Astring: string);
    function Varcond_Specified(Index: Integer): boolean;
    procedure SetAmount(Index: Integer; const Astring: string);
    function Amount_Specified(Index: Integer): boolean;
    procedure SetUnit_(Index: Integer; const Astring: string);
    function Unit__Specified(Index: Integer): boolean;
    procedure SetTotalAmount(Index: Integer; const Astring: string);
    function TotalAmount_Specified(Index: Integer): boolean;
    procedure SetCurrency(Index: Integer; const Astring: string);
    function Currency_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property OrderPos:   string     Index (IS_OPTN) read FOrderPos write SetOrderPos stored OrderPos_Specified;
    property Condition:  string     Index (IS_OPTN) read FCondition write SetCondition stored Condition_Specified;
    property Description: string     Index (IS_OPTN) read FDescription write SetDescription stored Description_Specified;
    property Varcond:    string     Index (IS_OPTN) read FVarcond write SetVarcond stored Varcond_Specified;
    property Amount:     string     Index (IS_OPTN) read FAmount write SetAmount stored Amount_Specified;
    property Quantity:   TXSDecimal read FQuantity write FQuantity;
    property Unit_:      string     Index (IS_OPTN) read FUnit_ write SetUnit_ stored Unit__Specified;
    property TotalAmount: string     Index (IS_OPTN) read FTotalAmount write SetTotalAmount stored TotalAmount_Specified;
    property Currency:   string     Index (IS_OPTN) read FCurrency write SetCurrency stored Currency_Specified;
    property ListPrice:  TXSDecimal Index (IS_NLBL) read FListPrice write FListPrice;
  end;


  // ************************************************************************ //
  // Namespace : http://www.servadr.de/
  // soapAction: http://www.servadr.de/%operationName%
  // Transport : http://schemas.xmlsoap.org/soap/http
  // Stil    : document
  // Verwenden von      : literal
  // Bindung  : SalesServiceSoap12
  // Service  : SalesService
  // Port     : SalesServiceSoap12
  // URL      : https://***.servadr.de/services/api/salesservice.asmx
  // ************************************************************************ //
  SalesServiceSoap = interface(IInvokable)
  ['{396126E1-AD85-AECB-491F-8E2880413151}']

    // Header: WebLogin:pIn
    function DealerInformationPerVehicle(const vehicleNumber: string): DealerInformationModel; stdcall;

    // Header: WebLogin:pIn
    function EquipmentPerVehicle(const vehicleNumber: string): ArrayOfEquipmentModel; stdcall;

    // Header: WebLogin:pIn
    function PaymentConditions(const vehicleNumber: string): ArrayOfPaymentConditionModel; stdcall;

    // Header: WebLogin:pIn
    function CompleteVehicleInformation(const vehicleNumber: string): CompleteVehicleInformationModel; stdcall;
  end;

function GetSalesServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): SalesServiceSoap;
Aufruf im Program
Delphi-Quellcode:
var
myService : SalesServiceSoap;
myLogin : WebLogin;
myInfo : CompleteVehicleInformationModel;
myEquipment : ArrayOfEquipmentModel;

begin
 myService := GetSalesServiceSoap();
 myLogin := WebLogin.Create;
 myLogin.User := edt1.Text;
 myLogin.Password := edt2.Text;
 myLogin.Language := 1;
 myInfo := myService.CompleteVehicleInformation(edt3.text); // <= hier kommt der Fehler!
...
Was mach ich falsch?

hoika 15. Jan 2020 14:23

AW: Problem beim SOAP Abruf
 
Hallo,
laut dem hier
https://entwickler-forum.de/forum/ar...9-soap-problem
liegt es an einem NIL-Pointer

Du benutzt das WebLogin-Objekt (den SOAP-Header) ja auch gar nicht.
Schau mal hier http://docwiki.embarcadero.com/RADSt...g_SOAP_Headers.

Blackpit 15. Jan 2020 15:37

AW: Problem beim SOAP Abruf
 
Zitat:

Zitat von hoika (Beitrag 1455216)
...

Du benutzt das WebLogin-Objekt (den SOAP-Header) ja auch gar nicht.
Schau mal hier http://docwiki.embarcadero.com/RADSt...g_SOAP_Headers.

War ein Kopierfehler (oben korrigiert), ich benutze es schon. Den Link kannte ich auch schon, es sind auch alle Parameter gefüllt.
Wie, ausser mit WireShark o.a., kann ich hier debuggen?

hoika 15. Jan 2020 16:02

AW: Problem beim SOAP Abruf
 
Hallo,
hm, wo genau benutzt Du den Header?

http://docwiki.embarcadero.com/RADSt...t_Applications

Meines Erachtens fehlt ein

Delphi-Quellcode:
 
(myService as ISOAPHeaders).Send(myLogin); { add the header to outgoing message }
vor dem
Delphi-Quellcode:
 
  myInfo := myService.CompleteVehicleInformation(edt3.text);

Blackpit 15. Jan 2020 16:32

AW: Problem beim SOAP Abruf
 
Hallo Heiko,

ich denke auch das hier der Hund begraben ist.
Dein Vorschlag läuft durch, ändert aber leider nichts am Problem.

Blackpit 15. Jan 2020 19:10

AW: Problem beim SOAP Abruf
 
Ich komm nicht weiter, deshalb nochmals die Frage:
Zitat:

Zitat von Blackpit (Beitrag 1455224)
...Wie, ausser mit WireShark o.a., kann ich hier debuggen?

Danke im Voraus!

hoika 15. Jan 2020 20:26

AW: Problem beim SOAP Abruf
 
Hallo,
zeig doch noch mal den geänderten Code.
Und bitte nicht im alten Post ändern, sondern hier neu reinstellen.

Blackpit 16. Jan 2020 10:04

AW: Problem beim SOAP Abruf
 
Delphi-Quellcode:
procedure TForm3.btn1Click(Sender: TObject);
var
myService : SalesServiceSoap;
myLogin : WebLogin;
myDealer : DealerInformationModel;
myInfo : CompleteVehicleInformationModel;
myEquipment : ArrayOfEquipmentModel;
//myHeader : ISOAPHeaders;

begin
 myService := GetSalesServiceSoap();
 myLogin := WebLogin.Create;
 myLogin.User := edt1.Text;
 myLogin.Password := edt2.Text;
 myLogin.Language := 1;
 //myHeader := myService as ISOAPHeaders;
 //myHeader.Send(myLogin); { add the header to outgoing message }
 (myService as ISOAPHeaders).Send(myLogin); { add the header to outgoing message }
 myInfo := myService.CompleteVehicleInformation(edt3.text);
 myEquipment := myService.CompleteVehicleInformation(edt3.text).Equipment;
end;
end;
Läuft durch,der Fehler bleibt :(

hoika 16. Jan 2020 10:47

AW: Problem beim SOAP Abruf
 
Hallo,
myInfo := myService.CompleteVehicleInformation(edt3.text);
myEquipment := myService.CompleteVehicleInformation(edt3.text).Eq uipment;

in welcher der beiden Zeilen?

BTW:
myEquipment := myService.CompleteVehicleInformation(edt3.text).Eq uipment;
macht für mich erst mal keinen Sinn.
Ich könnte ja gleich
myInfo..Equipment;
benutzen

Blackpit 16. Jan 2020 12:20

AW: Problem beim SOAP Abruf
 
Es ist alles beim alten, myinfo ist die komplette Fahrzeuginfo, der Rest sind Teilbereiche im Service abrufbar.
Ich suche jetzt einen Weg das Protokol auszulesen, der Service funktioniert grundsätzlich per SoapUI.
Ich würde es gerne verstehen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:05 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz