So I'm consuming SOAP services using Delphi, but struggling to set the value of an enum. Below is the enum declaration:
Extension = (pdf, xls, txt, xlsx, docx, doc, xml, png, jpg, gif);
This is declared in the unit Delphi imports once you import the WSDL. Now my app is using this unit, and I've tried below options, but to no avail.
Option 1: (Doesn't compile. Undeclared identifier: 'pdf')
uses SOAPAPI_Unit
type
Extension = SOAPAPI_Unit.Extension;
....
procedure TForm1.Button2Click(Sender: TObject);
var
Ext : Extension;
begin
Document.Extension := pdf;
end;
Option 2: (Compiles, but I get a server error saying object ref not set)
uses SOAPAPI_Unit
....
procedure TForm1.Button2Click(Sender: TObject);
var
Ext : SOAPAPI_Unit.Extension;
begin
Document.Extension := Ext(0);
end;
Option 3 (Re-Declare the Enum in the main .pas file, but then I get Incompatible types: 'SOAPAPI_Unit.Extension' and 'formMain.Extension')
uses SOAPAPI_Unit
type
Extension = (pdf, xls, txt, xlsx, docx, doc, xml, png, jpg, gif);
....
procedure TForm1.Button2Click(Sender: TObject);
var
Ext : Extension;
begin
Document.Extension := pdf;
end;
Option 4 (Compiles, but get object ref not set error from server)
uses SOAPAPI_Unit
....
procedure TForm1.Button2Click(Sender: TObject);
var
Ext : Extension;
begin
Document.Extension := Ext.pdf;
end;
Document.Extension := Extension.pdfor isExtensionclashes with something else then `Document.Extension := SOAPAPI_Unit.Extension.pdf. Attempting to re-declare the type is never going to work. Surely you appreciate why that is so. Don't guess. Try to understand. - David Heffernan