I consume a web service that uses positive and negative numbers to indicate if the web service call was successful, and if it wasn’t, the numbers indicate the type of error. Using the WSDL importer (in Delphi 2007, Delphi 2010, and Delphi XE), I get this type definition:
PCRUpdateCodes = (_7, _6, _5, _4, _3, _2, _1, _1, _2, _3, _4);
In the WSDL, the last four entries on the right are negative numbers. The Delphi compiler gives me an error “Identifier redeclared” for the last four entries. How can I make the last four entries negative numbers?
Here is the relevant portion of the WSDL.
<xs:simpleType name="PCRUpdateCodes">
<xs:annotation>
<xs:documentation>Codes to describe return codes for an attempted PCR import web service operation</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:integer">
<xs:enumeration value="-7">
<xs:annotation>
<xs:documentation>Permission denied to the client for that organization</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-6">
<xs:annotation>
<xs:documentation>Permission denied to the client for the operation</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-5">
<xs:annotation>
<xs:documentation>Invalid username and/or password</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-4">
<xs:annotation>
<xs:documentation>Failed update of PCR, because no PCR exists with the same agency # and PCR #</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-3">
<xs:annotation>
<xs:documentation>Failed update of PCR marked incomplete, because PCR was previously marked complete</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-2">
<xs:annotation>
<xs:documentation>Failed update of PCR, because of failing NEMSIS XML validation</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="-1">
<xs:annotation>
<xs:documentation>Failed update of PCR marked complete, because of failing logical validation</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="1">
<xs:annotation>
<xs:documentation>Successful update of PCR marked incomplete, but failing logical validation</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="2">
<xs:annotation>
<xs:documentation>Successful update of PCR marked incomplete</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="3">
<xs:annotation>
<xs:documentation>Successful update of PCR marked complete, previously marked incomplete</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="4">
<xs:annotation>
<xs:documentation>Successful update of PCR marked complete, previously marked complete, now marked amended</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="5">
<xs:annotation>
<xs:documentation>Successful update of PCR marked complete, previously marked incomplete, but with validation warnings</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="6">
<xs:annotation>
<xs:documentation>Successful update of PCR marked complete, previously marked complete, now marked amended, but with validation warnings</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
I have tried the definition of your enumeration with WsdlImp.exe 15.0.3953.35171 provided by Delphi XE (Update 1). Option “Validate Enumeration members” is checked.
Here is the code for the generated enumeration.
And the registration code for the enumeration values.
Looks like it is alright to me. If you do not get this it could be that you have an older version of WsdlImp.exe. A last resort would be to modify your generated code by hand.