WSDL - Object Reference not set to an instance of an Object

Asked

Viewed 294 times

0

In the code below the lReturn variable must contain a string with an xml returned from the web service, but the value returned by lRetorno:= ws.WS_Eleg_Portador(ws_aux); is being the message 'Object Reference not set to an instance of an Object'. The communication with web service is ok, because in another function I was able to capture the data normally. I am developing in Lazarus for Linux, the language is Free Pascal, someone knows what could be?

procedure TPharmaLink.Pac_Eleg_Portador(const pAutorizacao: String; var pTransacao: RTransacaoPBM);
var
 ws      : ConcentradorSoap;
 ws_aux  : WS_Eleg_Portador_Type;
 lRetorno: WS_Eleg_PortadorResponse;
 lCartao : String;
 lCPF    : String;
 lTimeStm: String;
 begin
 inherited;

 FPC_RegisterHTTP_Transport(); //InvRegistry.RegisterInvokeOptions(TypeInfo(concentradorSoap), ioDocument);

 lCartao := '';
 lCPF    := '0';
 lTimeStm:= DateTimeToStr(Now);
 lTimeStm:= StringReplace(lTimeStm,'/','',[rfReplaceAll]);
 lTimeStm:= StringReplace(lTimeStm,':','',[rfReplaceAll]);
 lTimeStm:= StringReplace(lTimeStm,' ','',[rfReplaceAll]);

 if Length(pAutorizacao) = 16
 then lCartao:= pAutorizacao
 else lCPF   := pAutorizacao;

 pTransacao.Erro:= '';

 // Instanciando os objetos
 ws_aux   := WS_Eleg_Portador_Type.Create();
 //lRetorno:= ws.WS_Eleg_Portador(Trim(GetIdentificacao), FProjeto, lTimeStm, lCartao, StrToInt64(lCpf), '' );
 ws_aux.cIdentifica :=Trim(GetIdentificacao);
 ws_aux.cProjeto    :='SAN001';
 ws_aux.cTimestamp  :=lTimeStm;
 ws_aux.cCartao     :=lCartao;
 ws_aux.nCPF        :=StrToInt64(lCpf);
 ws_aux.cCanal      :='';

 ws := wst_CreateInstance_ConcentradorSoap();

 try
     lRetorno:= ws.WS_Eleg_Portador(ws_aux);
 except
     on E: Exception do
        pTransacao.Erro:= E.Message;
 end;

 [continua...]

1 answer

0


I was able to find the problem in my code: I changed my ws_aux.cCanal := ''; for ws_aux.cCanal := ' ';. I don’t know why, but Lazarus didn’t recognize '' as empty in web service, so the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.