Delphi 带有负数的枚举类型的WSDL导入器

Delphi 带有负数的枚举类型的WSDL导入器,delphi,wsdl,Delphi,Wsdl,我使用一个web服务,它使用正数和负数来指示web服务调用是否成功,如果没有成功,则这些数字指示错误的类型。使用WSDL导入器(在Delphi 2007、Delphi 2010和Delphi XE中),我得到了以下类型定义: PCRUpdateCodes=(_7、_6、_5、_4、_3、_2、_1、_1、_2、_3、_4) 在WSDL中,右边的最后四个条目是负数。Delphi编译器为最后四个条目提供了一个错误“重新声明标识符”。如何将最后四项设为负数 下面是WSDL的相关部分 <xs:s

我使用一个web服务,它使用正数和负数来指示web服务调用是否成功,如果没有成功,则这些数字指示错误的类型。使用WSDL导入器(在Delphi 2007、Delphi 2010和Delphi XE中),我得到了以下类型定义:

PCRUpdateCodes=(_7、_6、_5、_4、_3、_2、_1、_1、_2、_3、_4)

在WSDL中,右边的最后四个条目是负数。Delphi编译器为最后四个条目提供了一个错误“重新声明标识符”。如何将最后四项设为负数

下面是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>

用于描述尝试的PCR导入web服务操作的返回代码的代码
对该组织的客户端的权限被拒绝
对客户端的操作权限被拒绝
无效的用户名和/或密码
PCR更新失败,因为不存在具有相同机构和PCR的PCR#
更新标记为不完整的PCR失败,因为PCR以前标记为完整
由于NEMSIS XML验证失败,PCR更新失败
由于逻辑验证失败,标记为完成的PCR更新失败
PCR成功更新,标记不完整,但逻辑验证失败
PCR标记不完整的成功更新
成功更新PCR标记为已完成,以前标记为未完成
PCR成功更新,标记为完成,以前标记为完成,现在标记为修订
PCR成功更新,标记为完成,以前标记为未完成,但带有验证警告
PCR成功更新,标记为完成,以前标记为完成,现在标记为修订,但带有验证警告

我使用Delphi XE提供的WsdlImp.exe 15.0.3953.35171(更新1)尝试了枚举的定义。选中“验证枚举成员”选项

下面是生成的枚举的代码

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。最后一种方法是手工修改生成的代码。

WSDL导入器对这些情况不使用良好的默认名称,但只要保持“RegisterExternalPropName”调用的最新状态,您就可以随意更改它们。例如,将“_12”分别更改为“One”和“_7”分别更改为“NegSeven”,并更新相应的RegisterExternalPropName调用。本机成员名称对服务并不重要,只有在XML中生成的外部名称才重要。谢谢你们的帮助。改变单元底部的注册呼叫就成功了。