Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   WSDL wird von Delphi XE3 falsch importiert (https://www.delphipraxis.net/190673-wsdl-wird-von-delphi-xe3-falsch-importiert.html)

zahnmeissel 25. Okt 2016 08:03

Delphi-Version: XE3

WSDL wird von Delphi XE3 falsch importiert
 
Guten Morgen Zusammen,

mit dem WSDL-Importer von Delphi möchte ich folgendes WSDL importieren:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="CalculationService" targetNamespace="http://services.ws.dvce.fce.ford.com/" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tns="http://services.ws.dvce.fce.ford.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
   <types>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://services.ws.dvce.fce.ford.com/" version="1.0" targetNamespace="http://services.ws.dvce.fce.ford.com/">

         <xs:element name="AdditionalInformation" type="tns:AdditionalInformation"/>

         <xs:element name="calculate" type="tns:calculate"/>

         <xs:complexType name="calculate">
            <xs:sequence>
               <xs:element ref="tns:AdditionalInformation" minOccurs="0"/>
            </xs:sequence>
         </xs:complexType>

         <xs:complexType name="AdditionalInformation">
            <xs:sequence>
               <xs:element name="requestedResponseElements" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
         </xs:complexType>

      </xs:schema>
   </types>
   <message name="calculate">
      <part name="parameters" element="tns:calculate">
      </part>
   </message>
   <portType name="CalculationService">
      <operation name="calculate">
         <input message="tns:calculate" wsam:Action="CalculationService.calculate">
         </input>
      </operation>
   </portType>
   <binding name="CalculationServicePortBinding" type="tns:CalculationService">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="calculate">
         <soap:operation soapAction="CalculationService.calculate"/>
         <input>
            <soap:body use="literal"/>
         </input>
         <output>
            <soap:body use="literal"/>
         </output>
      </operation>
   </binding>
   <service name="CalculationService">
      <port name="CalculationServicePort" binding="tns:CalculationServicePortBinding">
         <soap:address location="http://localhost:11000/DEVICEWebNew/CalculationService"/>
      </port>
   </service>
</definitions>
Aber was Delphi daraus macht verstehe ich nicht und hoffe auf Eure Hilfe. Dies ist das von Delphi erzeugte Ergebnis:

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

// WSDL    : C:\temp\device\DEVICEEAR.ear\DEVICEWeb.war\generatedWSDLDir\DEVICEWebNew\Strip\CalculationService.wsdl
//  >Import : C:\temp\device\DEVICEEAR.ear\DEVICEWeb.war\generatedWSDLDir\DEVICEWebNew\Strip\CalculationService.wsdl>0
// Codierung : UTF-8
// Version: 1.0
// (25.10.2016 08:52:10 - - $Rev: 52705 $)
// ************************************************************************ //

unit CalculationService1;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

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


  AdditionalInformation2 = array of string;    { "http://services.ws.dvce.fce.ford.com/"[GblCplx] }
  AdditionalInformation = type AdditionalInformation2;     { "http://services.ws.dvce.fce.ford.com/"[GblElm] }

  // ************************************************************************ //
  // Namespace : http://services.ws.dvce.fce.ford.com/
  // soapAction: CalculationService.calculate
  // Transport : http://schemas.xmlsoap.org/soap/http
  // Stil    : document
  // Verwenden von      : literal
  // Bindung  : CalculationServicePortBinding
  // Service  : CalculationService
  // Port     : CalculationServicePort
  // URL      : http://localhost:11000/DEVICEWebNew/CalculationService
  // ************************************************************************ //
  CalculationService = interface(IInvokable)
  ['{E69DA24C-3802-99B3-0DAB-BB685B78C809}']
    procedure calculate(const AdditionalInformation: AdditionalInformation); stdcall;
  end;

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


implementation
  uses SysUtils;

function GetCalculationService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): CalculationService;
const
  defWSDL = 'C:\temp\device\DEVICEEAR.ear\DEVICEWeb.war\generatedWSDLDir\DEVICEWebNew\Strip\CalculationService.wsdl';
  defURL = 'http://localhost:11000/DEVICEWebNew/CalculationService';
  defSvc = 'CalculationService';
  defPrt = 'CalculationServicePort';
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 CalculationService);
    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
  { CalculationService }
  InvRegistry.RegisterInterface(TypeInfo(CalculationService), 'http://services.ws.dvce.fce.ford.com/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(CalculationService), 'CalculationService.calculate');
  InvRegistry.RegisterInvokeOptions(TypeInfo(CalculationService), ioDocument);
  { CalculationService.calculate }
  InvRegistry.RegisterParamInfo(TypeInfo(CalculationService), 'calculate', 'AdditionalInformation', '',
                                '', IS_REF);
  RemClassRegistry.RegisterXSInfo(TypeInfo(AdditionalInformation2), 'http://services.ws.dvce.fce.ford.com/', 'AdditionalInformation2', 'AdditionalInformation');
  RemClassRegistry.RegisterXSInfo(TypeInfo(AdditionalInformation), 'http://services.ws.dvce.fce.ford.com/', 'AdditionalInformation');

end.
Da im WSDL "AdditionalInforamtion" als complexType definiert ist hätte ich auch erwartet dass Delphi daraus die Klasse "AdditionalInformation" generiert.
Also in etwa so:

Delphi-Quellcode:
  AdditionalInformation2 = class;              { "http://services.ws.dvce.fce.ford.com/"[GblCplx] }
  AdditionalInformation = class;               { "http://services.ws.dvce.fce.ford.com/"[GblElm] }



  Array_of_String = array of string;

  // ************************************************************************ //
  // XML      : AdditionalInformation, global, <complexType>
  // Namespace : http://services.ws.dvce.fce.ford.com/
  // ************************************************************************ //
  AdditionalInformation2 = class(TRemotable)
  private
    FrequestedResponseElements: Array_of_String;
    FrequestedResponseElements_Specified: boolean;
    procedure SetrequestedResponseElements(Index: Integer; const Values: Array_of_String);
    function requestedResponseElements_Specified(Index: Integer): boolean;
  published
    property requestedResponseElements: Array_of_String Index (IS_OPTN or IS_UNQL) read FrequestedResponseElements write SetrequestedResponseElements stored requestedResponseElements_Specified;
  end;



  // ************************************************************************ //
  // XML      : AdditionalInformation, global, <element>
  // Namespace : http://services.ws.dvce.fce.ford.com/
  // ************************************************************************ //
  AdditionalInformation = class(AdditionalInformation2)
  private
  published
  end;
Mir ist schleierhaft wieso Delphi aus "AdditionalInformation" ein Array generiert.

Wenn ich das in Eclipse importiere oder mir über SoapUI aus dem WSDL einen Request erzeugen lassen funktioniert alles wie erwartet!

Ist Euch sowas schon einmal untergekommen?
Habt Ihr eine Idee wie das zu lösen ist?
Habe ich irgendwo ein Häkchen vergessen oder ist das WSDL falsch?

Das WSDL liegt unter meiner Kontrolle und kann entsprechend den Anforderungen geändert werden!

Vielen Dank für Eure Bemühungen!

Gruß
Falk Termast

Sherlock 25. Okt 2016 08:10

AW: WSDL wird von Delphi XE3 falsch importiert
 
Funktioniert es denn nicht?

Sherlock

zahnmeissel 25. Okt 2016 08:52

AW: WSDL wird von Delphi XE3 falsch importiert
 
Nein, da ja nicht die zu erwartende Klasse AdditionalInformation generiert wird!

Sherlock 25. Okt 2016 09:49

AW: WSDL wird von Delphi XE3 falsch importiert
 
Also ein Testlauf schlägt fehl? Ich frage das nur, weil ich keine konkrete Fehlermeldung gesehen habe. Ich habe mir noch nie die WSDL angesehen, die Delphi generiert, und ich habe so einiges über WSDL getan.

Sherlock

zahnmeissel 25. Okt 2016 11:41

AW: WSDL wird von Delphi XE3 falsch importiert
 
Wenn ich in der Methode "calculate" für den Übergabeparameter "AdditionalInformation" erwarte dass dort ein Objekt übergeben wird (so ist es ja auch in der WSDL deklariert), Delphi aber mit Hilfe des WSDL-Importers als Übergabeparameter einen String-Typ implementiert brauche ich nicht über irgendwelche Testläufe nachdenken.
Der zu übergebende Typ ist falsch und ich würde gerne wissen wieso Delphi beim Import dieser Fehler unterläuft, bzw. wie das WSDL aufgebaut sein muss damit der richtige Übergabeparameter von Delphi erzeugt wird.

Sherlock 25. Okt 2016 12:19

AW: WSDL wird von Delphi XE3 falsch importiert
 
Ich kann Dir leider nichts zum Warum sagen, nur zum Was. Und das Was ist nunmal so, daß die soap.pas automatisch erzeugt wird, und automatisch erzeugte Dateien in Delphi sich zickig verhalten, wenn man an ihnen hantiert (zumindest war das bei D2007 noch so, als ich das letzte Mal an einem ActiveX-Wrapper etwas ändern wollte). Ich bin allerdings auch einer von der alten Schule: "Probieren geht über studieren" und nehme hin, was Delphi mir so vorsetzt, bis es mal zu einem Fehler kommt. Das hat mir in der Vergangenheit echt viel Zeit erspart.

Also viel Erfolg bei der Recherche.

Sherlock


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:42 Uhr.

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