【问题标题】:WSDL importer for enumerated types with negative numbers带有负数的枚举类型的 WSDL 导入器
【发布时间】:2011-03-14 17:52:56
【问题描述】:

我使用一个 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>

【问题讨论】:

    标签: delphi wsdl


    【解决方案1】:

    我已经尝试使用 Delphi XE(更新 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。最后的手段是手动修改生成的代码。

    【讨论】:

    • WSDL 导入器不会为这些情况使用好的默认名称,但您可以根据需要更改它们,只要您保持“RegisterExternalPropName”调用是最新的。例如,分别将“_12”更改为“One”,将“_7”更改为“NegSeven”,并更新相应的 RegisterExternalPropName 调用。本机成员名称与服务无关 - 只有在 XML 中生成的外部名称才重要。
    • 感谢两位的帮助。更改单元底部的注册电话就可以了。
    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 2013-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    相关资源
    最近更新 更多