我使用一个使用正数和负数的Web服务来指示Web服务调用是否成功,如果不成功,则数字表示错误类型。使用WSDL导入器(在Delphi 2007,Delphi 2010和Delphi XE中),我得到了这种类型的定义:
PCRUpdateCodes =(_ 7,_6,_5,_4,_3,_2,_1,_1,_2,_3,_4);
在WSDL中,右边的最后四个条目是负数。 Delphi编译器在最后四个条目中给出了一个错误“Identifier redeclared”。如何将最后四个条目设为负数?
这是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>
答案 0 :(得分:2)
我已尝试使用Delphi XE(Update 1)提供的WsdlImp.exe 15.0.3953.35171定义您的枚举。选中“验证枚举成员”选项。
以下是生成的枚举的代码。
TEnumTest = (
_7,
_6,
_5,
_4,
_3,
_2,
_1,
_12,
_22,
_32,
_42,
_52,
_62
);
枚举值的注册码。
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_7', '-7');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_6', '-6');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_5', '-5');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_4', '-4');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_3', '-3');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_2', '-2');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_1', '-1');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_12', '1');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_22', '2');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_32', '3');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_42', '4');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_52', '5');
RemClassRegistry.RegisterExternalPropName(TypeInfo(TEnumTest), '_62', '6');
看起来对我来说没问题。如果你没有得到这个,可能是你有一个旧版本的WsdlImp.exe。最后一种方法是手动修改生成的代码。