WSDL импортер для перечислимых типов с отрицательными числами - PullRequest
2 голосов
/ 14 марта 2011

Я использую веб-службу, которая использует положительные и отрицательные числа, чтобы указать, был ли вызов веб-службы успешным, и если это не так, числа указывают тип ошибки.Используя средство импорта 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>

1 Ответ

2 голосов
/ 14 марта 2011

Я попытался определить ваше перечисление с WsdlImp.exe 15.0.3953.35171, предоставленным Delphi XE (обновление 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. Последним средством будет изменение вашего сгенерированного кода вручную.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...