Recent

Author Topic: Web Service Toolkit  (Read 660 times)

cefantacini

  • Newbie
  • Posts: 1
Web Service Toolkit
« on: December 25, 2020, 02:53:23 pm »
I imported the WebService

http://sngpc.anvisa.gov.br/webservice/sngpc.asmx

For the method EnviaArquivoSNGPC he created the class:

Code: Pascal  [Select][+][-]
  1.   EnviaArquivoSNGPC_Type = class(TBaseComplexRemotable)
  2.   private
  3.     FEmail : String;
  4.     FSenha : String;
  5.     FArq : TBase64StringRemotable;
  6.     FHashIdentificacao : String;
  7.   private
  8.     function wstHas_Email() : Boolean;
  9.     function wstHas_Senha() : Boolean;
  10.     function wstHas_Arq() : Boolean;
  11.     function wstHas_HashIdentificacao() : Boolean;
  12.   public
  13.     constructor Create();override;
  14.     procedure FreeObjectProperties();override;
  15.   published
  16.     property Email : String read FEmail write FEmail stored wstHas_Email;
  17.     property Senha : String read FSenha write FSenha stored wstHas_Senha;
  18.     property Arq : TBase64StringRemotable read FArq write FArq stored wstHas_Arq;
  19.     property HashIdentificacao : String read FHashIdentificacao write FHashIdentificacao stored wstHas_HashIdentificacao;
  20.   end;

I can't use the parameter Arq: TBase64StringRemotable

For what I researched I need to register it with

RegisterAttributeProperty()

Follow the code:

Code: Pascal  [Select][+][-]
  1. var ClasseSNGPC : sngpcSoap;
  2.     Arquivo : EnviaArquivoSNGPC_Type;
  3. .
  4. .
  5. .
  6. begin
  7.   SYNAPSE_RegisterHTTP_Transport( );
  8.   ClasseSNGPC := wst_CreateInstance_sngpcSoap( );
  9.   Arquivo := EnviaArquivoSNGPC_Type.Create();
  10.   Arquivo.Email := eMail;
  11.   Arquivo.Senha := Senha;
  12.   Arquivo.Arq.EncodedString := StringBase64;
  13.   Arquivo.HashIdentificacao := Hash;
  14.   try
  15.     ClasseSNGPC.EnviaArquivoSNGPC( Arquivo );
  16.   except
  17.     on e: Exception do
  18.       ShowMessage( E.Message );
  19.   end;

Error:

Service exception :
   Code = "soap:Server"
   Message = "System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: buffer
   at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer)
   at sngpc.sngpc.GetMD5HashFromByte(Byte[] file) in C:\inetpub\wwwroot\sngpc\webservice\sngpc.asmx.cs:line 479
   at sngpc.sngpc.EnviaArquivoSNGPC(String Email, String Senha, Byte[] Arq, String HashIdentificacao) in C:\inetpub\wwwroot\sngpc\webservice\sngpc.asmx.cs:line 902
   --- End of inner exception stack trace ---"

[Edited to add code tags - please see How to use the Forums.]
« Last Edit: December 25, 2020, 10:09:51 pm by trev »

 

TinyPortal © 2005-2018