2011-03-14 101 views
2

我使用Web服務使用正數和負數來指示Web服務調用是否成功,如果不是,則數字指示錯誤的類型。使用WSDL導入程序(在Delphi 2007,Delphi 2010和Delphi XE中),我得到這種類型定義:具有負數的枚舉類型的WSDL導入程序

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> 

回答

2

我已經試過你列舉的與WsdlImp.exe 15.0.3953.35171的定義中,德爾福XE(更新一)提供。選項「驗證枚舉成員」被選中。

以下是生成的枚舉的代碼。

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。最後的手段是手動修改您生成的代碼。

+2

WSDL Importer對這些情況不使用良好的默認名稱,但只要您保持「RegisterExternalPropName」調用爲最新,您可以根據需要更改它們。例如,分別將'_12'更改爲'One'和'_7',並更新相應的RegisterExternalPropName調用。本機成員名稱與服務無關 - 只有在XML中生成的外部名稱很重要。 – BruneauB 2011-03-14 20:00:41

+0

謝謝你們的幫助。改變單位底部的註冊電話也有訣竅。 – 2011-03-20 23:35:30