Delphi 处理错误SOAP客户端

Delphi 处理错误SOAP客户端,delphi,exception,soap,wsdl,fault,Delphi,Exception,Soap,Wsdl,Fault,我需要在Delphi2007中编写一个带有SSL的SOAP客户端。 我使用WSDL导入器$Rev:10138生成代码。我在错误处理方面有问题。 代码中包括以下类 SzczegolyBledu = class(TRemotable) private Fkod: KodBledu; Fzrodlo: KrotkiTekst; Fopis: KrotkiTekst; published property kod: KodBledu read Fkod write Fkod

我需要在Delphi2007中编写一个带有SSL的SOAP客户端。 我使用WSDL导入器$Rev:10138生成代码。我在错误处理方面有问题。 代码中包括以下类

SzczegolyBledu = class(TRemotable)
private
  Fkod: KodBledu;
  Fzrodlo: KrotkiTekst;
  Fopis: KrotkiTekst;
published
  property kod:    KodBledu     read Fkod write Fkod;
  property zrodlo: KrotkiTekst  read Fzrodlo write Fzrodlo;
  property opis:   KrotkiTekst  read Fopis write Fopis;
end;

BladTechniczny = class(ERemotableException)
private
  Fkod: KodBledu;
  Fopis: KrotkiTekst;
  Fopis_Specified: boolean;
  FopisTechniczny: DlugiTekst;
  FopisTechniczny_Specified: boolean;
  procedure Setopis(Index: Integer; const AKrotkiTekst: KrotkiTekst);
  function  opis_Specified(Index: Integer): boolean;
  procedure SetopisTechniczny(Index: Integer; const ADlugiTekst: DlugiTekst);
  function  opisTechniczny_Specified(Index: Integer): boolean;
published
  property kod:            KodBledu     read Fkod write Fkod;
  property opis:           KrotkiTekst  Index (IS_OPTN) read Fopis write Setopis stored opis_Specified;
  property opisTechniczny: DlugiTekst   Index (IS_OPTN) read FopisTechniczny write SetopisTechniczny stored opisTechniczny_Specified;
end;

bladTechniczny2 = class(BladTechniczny)
private
published
end;

Array_Of_SzczegolyBledu = array of SzczegolyBledu;   { -- }

BladBiznesowy = class(ERemotableException)
private
  Fkod: KodBledu;
  Fopis: KrotkiTekst;
  Fopis_Specified: boolean;
  Fszczegoly: Array_Of_SzczegolyBledu;
  Fszczegoly_Specified: boolean;
  procedure Setopis(Index: Integer; const AKrotkiTekst: KrotkiTekst);
  function  opis_Specified(Index: Integer): boolean;
  procedure Setszczegoly(Index: Integer; const AArray_Of_SzczegolyBledu: Array_Of_SzczegolyBledu);
  function  szczegoly_Specified(Index: Integer): boolean;
public
  destructor Destroy; override;
published
  property kod:       KodBledu                 read Fkod write Fkod;
  property opis:      KrotkiTekst              Index (IS_OPTN) read Fopis write Setopis stored opis_Specified;
  property szczegoly: Array_Of_SzczegolyBledu  Index (IS_OPTN) read Fszczegoly write Setszczegoly stored szczegoly_Specified;
end;

bladBiznesowy2 = class(BladBiznesowy)
private
published
end;

implementation

destructor BladBiznesowy.Destroy;
var
  I: Integer;
begin
  for I := 0 to Length(Fszczegoly)-1 do
    FreeAndNil(Fszczegoly[I]);
  SetLength(Fszczegoly, 0);
  inherited Destroy;
end; 

procedure BladBiznesowy.Setopis(Index: Integer; const AKrotkiTekst: KrotkiTekst);
begin
  Fopis := AKrotkiTekst;
  Fopis_Specified := True;
end;

function BladBiznesowy.opis_Specified(Index: Integer): boolean;
begin
  Result := Fopis_Specified;
end;

procedure BladBiznesowy.Setszczegoly(Index: Integer; const AArray_Of_SzczegolyBledu: Array_Of_SzczegolyBledu);
begin
  Fszczegoly := AArray_Of_SzczegolyBledu;
  Fszczegoly_Specified := True;
end;

function BladBiznesowy.szczegoly_Specified(Index: Integer): boolean;
begin
  Result := Fszczegoly_Specified;
end;

procedure BladTechniczny.Setopis(Index: Integer; const AKrotkiTekst: KrotkiTekst);
begin
  Fopis := AKrotkiTekst;
  Fopis_Specified := True;
end;

function BladTechniczny.opis_Specified(Index: Integer): boolean;
begin
  Result := Fopis_Specified;
end;

procedure BladTechniczny.SetopisTechniczny(Index: Integer; const ADlugiTekst: DlugiTekst);
begin
  FopisTechniczny := ADlugiTekst;
  FopisTechniczny_Specified := True;
end;

function BladTechniczny.opisTechniczny_Specified(Index: Integer): boolean;
begin
  Result := FopisTechniczny_Specified;
end;

initialization

  RemClassRegistry.RegisterXSClass(BladTechniczny, 'http://msw.gov.pl/srp/v3_0/uslugi/wspolne/', 'BladTechniczny');
  RemClassRegistry.RegisterXSClass(bladTechniczny2, 'http://msw.gov.pl/srp/v3_0/uslugi/subskrypcje/', 'bladTechniczny2', 'bladTechniczny');

  RemClassRegistry.RegisterXSClass(BladBiznesowy, 'http://msw.gov.pl/srp/v3_0/uslugi/wspolne/', 'BladBiznesowy');
  RemClassRegistry.RegisterXSClass(bladBiznesowy2, 'http://msw.gov.pl/srp/v3_0/uslugi/subskrypcje/', 'bladBiznesowy2', 'bladBiznesowy');
SOAPUI为我生成响应

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
   <soap:Body>
     <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Błąd: xxx</faultstring>
         <detail>
            <ns2:bladTechniczny xmlns:ns2="http://msw.gov.pl/srp/v3_0/uslugi/subskrypcje/">
               <kod>xxx</kod>
               <opisx>xxx</opis>
               <opisTechniczny></opisTechniczny>
            </ns2:bladTechniczny>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
在Delphi中没有生成RemotableException bladTechniczny,但我得到了EIdHTTPProtocolException
有没有办法改变它?

如果我点击web服务端点http://msw.gov.pl/srp/v3_0/uslugi/subskrypcje/,服务器重定向到https://msw.gov.pl/srp/v3_0/uslugi/subskrypcje/.


因此,我建议您使用https URI导入WSDL,然后重试。

服务器生成内部服务器错误。原因是数据请求的验证。在分析SoapUI中的响应时,我看到服务器发送错误消息。但我得到了一个异常EIdHTTPProtocolException,无法访问故障。我该如何处理故障?