WSDL - object reference not set to an instance of an object

0

In the code below the variable lRetorno 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'm developing on Lazarus for Linux, the language is Free Pascal, does anyone know what it 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...]
    
asked by anonymous 10.04.2015 / 15:12

1 answer

0

I was able to find the problem in my code: I've changed from ws_aux.cCanal := ''; to ws_aux.cCanal := ' '; . I do not know why, but Lazarus did not recognize '' as empty in the web service, so the problem.

    
04.05.2015 / 18:24