Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do when Delphi imports WSDL improperly due to a hyphen in an enum name?

I'm using Delphi and I'm using a wsdl file from another company to set up my proxy class to use their data from their web service. The wsdl file contains the following:

  <xsd:simpleType name="departStatus">
  <xsd:annotation>
   <xsd:documentation>Enumerates allowable departure statuses (DEPARTED, NOT-DEPARTED)</xsd:documentation>
   </xsd:annotation>
  <xsd:restriction base="xsd:string">
   <xsd:enumeration value="DEPARTED"/>
   <xsd:enumeration value="NOT-DEPARTED"/>
   </xsd:restriction>
   </xsd:simpleType>

When I generate the proxy class I get the following:

  departStatus = (
      DEPARTED, 
      [System.Xml.Serialization.XmlEnumAttribute('NOT-DEPARTED')]
      NOTDEPARTED);

Which doesn't compile unless I remove the line starting with [System.xml..., and it will not recognize "NOT-DEPARTED" as a valid value for departStatus. If I change "NOT-DEPARTED" to "NOT_DEPARTED" in the wsdl file and any incoming xml file it works fine, but the company that set this up is insisting that "NOT-DEPARTED" is valid and will not change it. Why isn't setting up the departStatus enumeration properly? Any ideas how to get around this? Thanks in advance for any help.

like image 361
Bob Sieffert Avatar asked May 03 '11 20:05

Bob Sieffert


2 Answers

I have a possible workaround:

Since departStatus is of the base type xsd:string, you should be able to change all occurences of the departStatus type to xsd:string in the WSDL file.

That way you can pass/interpret the string 'DEPARTED' or 'NON-DEPARTED' instead of using an enum.

like image 91
Jens Mühlenhoff Avatar answered Oct 21 '22 13:10

Jens Mühlenhoff


Delphi SOAP Runtime and Importer Update

http://cc.embarcadero.com/Item/24535

like image 33
Sam Avatar answered Oct 21 '22 15:10

Sam