PDA

Ver la Versión Completa : Consumir servicio soap sri ecuador


IVAND
21-07-2022, 01:29:21
Hola a todos , tengo un webservice (soap) que se le debe pasar un parametro (clave de acceso) para que me retome un archivo xml , soy nuevo en esto espero me den una luz de antemano gracias

https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl

el parametro que envia es clave de acceso 2908201901179001094500120051060000797057735934411

Eso me debe retornar un archivo xml

Nota : he estado leyendo los indy pero la verdad soy nuevo en esto y ando medio perdido

Gracias por su tiempo

movorack
21-07-2022, 18:12:42
Hola, ¿Cuál es tu duda?

Acá te dejo algunos enlaces que pueden ayudarte con este tema:

Importar un WSDL a Delphi: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Import_WSDL_Wizard
Como consumir un webservice soap: https://www.youtube.com/watch?v=jlRq4AqDpJo

Neftali [Germán.Estévez]
25-07-2022, 09:49:06
Nota : he estado leyendo los indy pero la verdad soy nuevo en esto y ando medio perdido


No comentas qué versión de Delphi estás utilizando.
Si tu versión (es de las nuevas) y ya incluye los componentes REST (TRESTClient, TRESTRequest, TRESTResponse), es mejor que lo intentes con estos componentes en lugar de las Indy.

egostar
25-07-2022, 18:03:19
;547557']No comentas qué versión de Delphi estás utilizando.
Si tu versión (es de las nuevas) y ya incluye los componentes REST (TRESTClient, TRESTRequest, TRESTResponse), es mejor que lo intentes con estos componentes en lugar de las Indy.

Que tal amigo Germán,

Es un Web Service SOAP. utilizando el WSDL Import sería mas fácil.

Saludos

IVAND
26-07-2022, 01:24:26
Hola a todos
Utilizo delphi 2009


uso el import wsl y me genera una unidad

AutorizacionComprobantesOffline = interface(IInvokable)
['{9454FB2D-D447-50CB-A1BE-8496232441E1}']
function autorizacionComprobante(const claveAccesoComprobante: string): respuestaComprobante; stdcall;
function autorizacionComprobanteLote(const claveAccesoLote: string): respuestaLote; stdcall;
end;



Esta me genera unas funciones

pero no se como acceder a ellas he utilizado un programa q se llama SoapUI 5.7.0 el cual coloco la url y me desplega unas opciones justamente es la funcion q le indico autorizacionComprobante -- la cual se debe pasar una clave de acceso (2007202207139187147300120010240000052940000004414) y me tendria q retornar un archivo xml con toda la informacion requerida para luego leer ese archivo y hacer varias cosas pero no se como llamar o donde almacear en resultado de esa funcion

Debo almacenar en un compobente memo

Utilizo ademas un componente HTTPRIO que vi en un manual por ahi q se debe usar junto a algunas funciones que salen ya automaticamente
en port sale esta opcion AutorizacionComprobantesOfflinePort
en service sale AutorizacionComprobantesOfflineService
wsdllocation sale https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl

adjunto archivo para ver si me dan una luz

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl
// >Import : https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl>0
// Encoding : UTF-8
// Version : 1.0
// (20/07/2022 18:55:26 - - $Rev: 19514 $)
// ************************************************************************ //

unit AutorizacionComprobantesOffline1;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
IS_OPTN = $0001;
IS_UNBD = $0002;
IS_UNQL = $0008;
IS_REF = $0080;


type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:dateTime - "http://www.w3.org/2001/XMLSchema"[Gbl]

respuestaComprobante = class; { "http://ec.gob.sri.ws.autorizacion"[GblCplx] }
autorizacion = class; { "http://ec.gob.sri.ws.autorizacion"[GblCplx] }
autorizacion2 = class; { "http://ec.gob.sri.ws.autorizacion"[GblElm] }
mensaje = class; { "http://ec.gob.sri.ws.autorizacion"[GblCplx] }
mensaje2 = class; { "http://ec.gob.sri.ws.autorizacion"[GblElm] }
respuestaLote = class; { "http://ec.gob.sri.ws.autorizacion"[GblCplx] }

autorizaciones = array of autorizacion2; { "http://ec.gob.sri.ws.autorizacion"[Cplx] }


// ************************************************************************ //
// XML : respuestaComprobante, global, <complexType>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
respuestaComprobante = class(TRemotable)
private
FclaveAccesoConsultada: string;
FclaveAccesoConsultada_Specified: boolean;
FnumeroComprobantes: string;
FnumeroComprobantes_Specified: boolean;
Fautorizaciones: autorizaciones;
Fautorizaciones_Specified: boolean;
procedure SetclaveAccesoConsultada(Index: Integer; const Astring: string);
function claveAccesoConsultada_Specified(Index: Integer): boolean;
procedure SetnumeroComprobantes(Index: Integer; const Astring: string);
function numeroComprobantes_Specified(Index: Integer): boolean;
procedure Setautorizaciones(Index: Integer; const Aautorizaciones: autorizaciones);
function autorizaciones_Specified(Index: Integer): boolean;
public
destructor Destroy; override;
published
property claveAccesoConsultada: string Index (IS_OPTN or IS_UNQL) read FclaveAccesoConsultada write SetclaveAccesoConsultada stored claveAccesoConsultada_Specified;
property numeroComprobantes: string Index (IS_OPTN or IS_UNQL) read FnumeroComprobantes write SetnumeroComprobantes stored numeroComprobantes_Specified;
property autorizaciones: autorizaciones Index (IS_OPTN or IS_UNQL) read Fautorizaciones write Setautorizaciones stored autorizaciones_Specified;
end;

mensajes = array of mensaje2; { "http://ec.gob.sri.ws.autorizacion"[Cplx] }


// ************************************************************************ //
// XML : autorizacion, global, <complexType>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
autorizacion = class(TRemotable)
private
Festado: string;
Festado_Specified: boolean;
FnumeroAutorizacion: string;
FnumeroAutorizacion_Specified: boolean;
FfechaAutorizacion: TXSDateTime;
FfechaAutorizacion_Specified: boolean;
Fambiente: string;
Fambiente_Specified: boolean;
Fcomprobante: string;
Fcomprobante_Specified: boolean;
Fmensajes: mensajes;
Fmensajes_Specified: boolean;
procedure Setestado(Index: Integer; const Astring: string);
function estado_Specified(Index: Integer): boolean;
procedure SetnumeroAutorizacion(Index: Integer; const Astring: string);
function numeroAutorizacion_Specified(Index: Integer): boolean;
procedure SetfechaAutorizacion(Index: Integer; const ATXSDateTime: TXSDateTime);
function fechaAutorizacion_Specified(Index: Integer): boolean;
procedure Setambiente(Index: Integer; const Astring: string);
function ambiente_Specified(Index: Integer): boolean;
procedure Setcomprobante(Index: Integer; const Astring: string);
function comprobante_Specified(Index: Integer): boolean;
procedure Setmensajes(Index: Integer; const Amensajes: mensajes);
function mensajes_Specified(Index: Integer): boolean;
public
destructor Destroy; override;
published
property estado: string Index (IS_OPTN or IS_UNQL) read Festado write Setestado stored estado_Specified;
property numeroAutorizacion: string Index (IS_OPTN or IS_UNQL) read FnumeroAutorizacion write SetnumeroAutorizacion stored numeroAutorizacion_Specified;
property fechaAutorizacion: TXSDateTime Index (IS_OPTN or IS_UNQL) read FfechaAutorizacion write SetfechaAutorizacion stored fechaAutorizacion_Specified;
property ambiente: string Index (IS_OPTN or IS_UNQL) read Fambiente write Setambiente stored ambiente_Specified;
property comprobante: string Index (IS_OPTN or IS_UNQL) read Fcomprobante write Setcomprobante stored comprobante_Specified;
property mensajes: mensajes Index (IS_OPTN or IS_UNQL) read Fmensajes write Setmensajes stored mensajes_Specified;
end;



// ************************************************************************ //
// XML : autorizacion, global, <element>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
autorizacion2 = class(autorizacion)
private
published
end;



// ************************************************************************ //
// XML : mensaje, global, <complexType>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
mensaje = class(TRemotable)
private
Fidentificador: string;
Fidentificador_Specified: boolean;
Fmensaje: string;
Fmensaje_Specified: boolean;
FinformacionAdicional: string;
FinformacionAdicional_Specified: boolean;
Ftipo: string;
Ftipo_Specified: boolean;
procedure Setidentificador(Index: Integer; const Astring: string);
function identificador_Specified(Index: Integer): boolean;
procedure Setmensaje(Index: Integer; const Astring: string);
function mensaje_Specified(Index: Integer): boolean;
procedure SetinformacionAdicional(Index: Integer; const Astring: string);
function informacionAdicional_Specified(Index: Integer): boolean;
procedure Settipo(Index: Integer; const Astring: string);
function tipo_Specified(Index: Integer): boolean;
published
property identificador: string Index (IS_OPTN or IS_UNQL) read Fidentificador write Setidentificador stored identificador_Specified;
property mensaje: string Index (IS_OPTN or IS_UNQL) read Fmensaje write Setmensaje stored mensaje_Specified;
property informacionAdicional: string Index (IS_OPTN or IS_UNQL) read FinformacionAdicional write SetinformacionAdicional stored informacionAdicional_Specified;
property tipo: string Index (IS_OPTN or IS_UNQL) read Ftipo write Settipo stored tipo_Specified;
end;



// ************************************************************************ //
// XML : mensaje, global, <element>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
mensaje2 = class(mensaje)
private
published
end;

autorizaciones2 = array of autorizacion2; { "http://ec.gob.sri.ws.autorizacion"[Cplx] }


// ************************************************************************ //
// XML : respuestaLote, global, <complexType>
// Namespace : http://ec.gob.sri.ws.autorizacion
// ************************************************************************ //
respuestaLote = class(TRemotable)
private
FclaveAccesoLoteConsultada: string;
FclaveAccesoLoteConsultada_Specified: boolean;
FnumeroComprobantesLote: string;
FnumeroComprobantesLote_Specified: boolean;
Fautorizaciones: autorizaciones2;
Fautorizaciones_Specified: boolean;
procedure SetclaveAccesoLoteConsultada(Index: Integer; const Astring: string);
function claveAccesoLoteConsultada_Specified(Index: Integer): boolean;
procedure SetnumeroComprobantesLote(Index: Integer; const Astring: string);
function numeroComprobantesLote_Specified(Index: Integer): boolean;
procedure Setautorizaciones(Index: Integer; const Aautorizaciones2: autorizaciones2);
function autorizaciones_Specified(Index: Integer): boolean;
public
destructor Destroy; override;
published
property claveAccesoLoteConsultada: string Index (IS_OPTN or IS_UNQL) read FclaveAccesoLoteConsultada write SetclaveAccesoLoteConsultada stored claveAccesoLoteConsultada_Specified;
property numeroComprobantesLote: string Index (IS_OPTN or IS_UNQL) read FnumeroComprobantesLote write SetnumeroComprobantesLote stored numeroComprobantesLote_Specified;
property autorizaciones: autorizaciones2 Index (IS_OPTN or IS_UNQL) read Fautorizaciones write Setautorizaciones stored autorizaciones_Specified;
end;


// ************************************************************************ //
// Namespace : http://ec.gob.sri.ws.autorizacion
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : AutorizacionComprobantesOfflineServiceSoapBinding
// service : AutorizacionComprobantesOfflineService
// port : AutorizacionComprobantesOfflinePort
// URL : https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline
// ************************************************************************ //
AutorizacionComprobantesOffline = interface(IInvokable)
['{9454FB2D-D447-50CB-A1BE-8496232441E1}']
function autorizacionComprobante(const claveAccesoComprobante: string): respuestaComprobante; stdcall;
function autorizacionComprobanteLote(const claveAccesoLote: string): respuestaLote; stdcall;
end;

function GetAutorizacionComprobantesOffline(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): AutorizacionComprobantesOffline;


implementation
uses SysUtils;

function GetAutorizacionComprobantesOffline(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): AutorizacionComprobantesOffline;
const
defWSDL = 'https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl';
defURL = 'https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline';
defSvc = 'AutorizacionComprobantesOfflineService';
defPrt = 'AutorizacionComprobantesOfflinePort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as AutorizacionComprobantesOffline);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


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

procedure respuestaComprobante.SetclaveAccesoConsultada(Index: Integer; const Astring: string);
begin
FclaveAccesoConsultada := Astring;
FclaveAccesoConsultada_Specified := True;
end;

function respuestaComprobante.claveAccesoConsultada_Specified(Index: Integer): boolean;
begin
Result := FclaveAccesoConsultada_Specified;
end;

procedure respuestaComprobante.SetnumeroComprobantes(Index: Integer; const Astring: string);
begin
FnumeroComprobantes := Astring;
FnumeroComprobantes_Specified := True;
end;

function respuestaComprobante.numeroComprobantes_Specified(Index: Integer): boolean;
begin
Result := FnumeroComprobantes_Specified;
end;

procedure respuestaComprobante.Setautorizaciones(Index: Integer; const Aautorizaciones: autorizaciones);
begin
Fautorizaciones := Aautorizaciones;
Fautorizaciones_Specified := True;
end;

function respuestaComprobante.autorizaciones_Specified(Index: Integer): boolean;
begin
Result := Fautorizaciones_Specified;
end;

destructor autorizacion.Destroy;
var
I: Integer;
begin
for I := 0 to System.Length(Fmensajes)-1 do
SysUtils.FreeAndNil(Fmensajes[I]);
System.SetLength(Fmensajes, 0);
SysUtils.FreeAndNil(FfechaAutorizacion);
inherited Destroy;
end;

procedure autorizacion.Setestado(Index: Integer; const Astring: string);
begin
Festado := Astring;
Festado_Specified := True;
end;

function autorizacion.estado_Specified(Index: Integer): boolean;
begin
Result := Festado_Specified;
end;

procedure autorizacion.SetnumeroAutorizacion(Index: Integer; const Astring: string);
begin
FnumeroAutorizacion := Astring;
FnumeroAutorizacion_Specified := True;
end;

function autorizacion.numeroAutorizacion_Specified(Index: Integer): boolean;
begin
Result := FnumeroAutorizacion_Specified;
end;

procedure autorizacion.SetfechaAutorizacion(Index: Integer; const ATXSDateTime: TXSDateTime);
begin
FfechaAutorizacion := ATXSDateTime;
FfechaAutorizacion_Specified := True;
end;

function autorizacion.fechaAutorizacion_Specified(Index: Integer): boolean;
begin
Result := FfechaAutorizacion_Specified;
end;

procedure autorizacion.Setambiente(Index: Integer; const Astring: string);
begin
Fambiente := Astring;
Fambiente_Specified := True;
end;

function autorizacion.ambiente_Specified(Index: Integer): boolean;
begin
Result := Fambiente_Specified;
end;

procedure autorizacion.Setcomprobante(Index: Integer; const Astring: string);
begin
Fcomprobante := Astring;
Fcomprobante_Specified := True;
end;

function autorizacion.comprobante_Specified(Index: Integer): boolean;
begin
Result := Fcomprobante_Specified;
end;

procedure autorizacion.Setmensajes(Index: Integer; const Amensajes: mensajes);
begin
Fmensajes := Amensajes;
Fmensajes_Specified := True;
end;

function autorizacion.mensajes_Specified(Index: Integer): boolean;
begin
Result := Fmensajes_Specified;
end;

procedure mensaje.Setidentificador(Index: Integer; const Astring: string);
begin
Fidentificador := Astring;
Fidentificador_Specified := True;
end;

function mensaje.identificador_Specified(Index: Integer): boolean;
begin
Result := Fidentificador_Specified;
end;

procedure mensaje.Setmensaje(Index: Integer; const Astring: string);
begin
Fmensaje := Astring;
Fmensaje_Specified := True;
end;

function mensaje.mensaje_Specified(Index: Integer): boolean;
begin
Result := Fmensaje_Specified;
end;

procedure mensaje.SetinformacionAdicional(Index: Integer; const Astring: string);
begin
FinformacionAdicional := Astring;
FinformacionAdicional_Specified := True;
end;

function mensaje.informacionAdicional_Specified(Index: Integer): boolean;
begin
Result := FinformacionAdicional_Specified;
end;

procedure mensaje.Settipo(Index: Integer; const Astring: string);
begin
Ftipo := Astring;
Ftipo_Specified := True;
end;

function mensaje.tipo_Specified(Index: Integer): boolean;
begin
Result := Ftipo_Specified;
end;

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

procedure respuestaLote.SetclaveAccesoLoteConsultada(Index: Integer; const Astring: string);
begin
FclaveAccesoLoteConsultada := Astring;
FclaveAccesoLoteConsultada_Specified := True;
end;

function respuestaLote.claveAccesoLoteConsultada_Specified(Index: Integer): boolean;
begin
Result := FclaveAccesoLoteConsultada_Specified;
end;

procedure respuestaLote.SetnumeroComprobantesLote(Index: Integer; const Astring: string);
begin
FnumeroComprobantesLote := Astring;
FnumeroComprobantesLote_Specified := True;
end;

function respuestaLote.numeroComprobantesLote_Specified(Index: Integer): boolean;
begin
Result := FnumeroComprobantesLote_Specified;
end;

procedure respuestaLote.Setautorizaciones(Index: Integer; const Aautorizaciones2: autorizaciones2);
begin
Fautorizaciones := Aautorizaciones2;
Fautorizaciones_Specified := True;
end;

function respuestaLote.autorizaciones_Specified(Index: Integer): boolean;
begin
Result := Fautorizaciones_Specified;
end;

initialization
InvRegistry.RegisterInterface(TypeInfo(AutorizacionComprobantesOffline), 'http://ec.gob.sri.ws.autorizacion', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(AutorizacionComprobantesOffline), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(AutorizacionComprobantesOffline), ioDocument);
RemClassRegistry.RegisterXSInfo(TypeInfo(autorizaciones), 'http://ec.gob.sri.ws.autorizacion', 'autorizaciones');
RemClassRegistry.RegisterXSClass(respuestaComprobante, 'http://ec.gob.sri.ws.autorizacion', 'respuestaComprobante');
RemClassRegistry.RegisterXSInfo(TypeInfo(mensajes), 'http://ec.gob.sri.ws.autorizacion', 'mensajes');
RemClassRegistry.RegisterXSClass(autorizacion, 'http://ec.gob.sri.ws.autorizacion', 'autorizacion');
RemClassRegistry.RegisterXSClass(autorizacion2, 'http://ec.gob.sri.ws.autorizacion', 'autorizacion2', 'autorizacion');
RemClassRegistry.RegisterXSClass(mensaje, 'http://ec.gob.sri.ws.autorizacion', 'mensaje');
RemClassRegistry.RegisterXSClass(mensaje2, 'http://ec.gob.sri.ws.autorizacion', 'mensaje2', 'mensaje');
RemClassRegistry.RegisterXSInfo(TypeInfo(autorizaciones2), 'http://ec.gob.sri.ws.autorizacion', 'autorizaciones2', 'autorizaciones');
RemClassRegistry.RegisterXSClass(respuestaLote, 'http://ec.gob.sri.ws.autorizacion', 'respuestaLote');

end.

Neftali [Germán.Estévez]
26-07-2022, 08:52:58
Es un Web Service SOAP.


Buen apunte Egostar, lo había leído "en diagonal" y no había visto eso.

Neftali [Germán.Estévez]
26-07-2022, 09:17:50
Coloca el componente y configura las propiedades: WSDLLocatoin, Service y Port (por ese orden). Si lo haces en orden, a partir de la primera, las otras puedes seleccionarlas en el desplegable.

Luego para hacer una prueba puedes hacer la siguiente llamada (coloca el componente y un TMemo en el form):

var
r:respuestaComprobante;
s:String;
begin
// Pedir autorización
r := GetAutorizacionComprobantesOffline.autorizacionComprobante('INCORRECTA');
// Acceder a los datos de respuesta
s := 'Consultada: ' + r.claveAccesoConsultada + ' - ' +
'Comprobantes: ' + r.numeroComprobantes + ' - ' +
'Autorizaciones: ' + Length(r.autorizaciones).ToString;

Memo1.Lines.Add(s);
Memo1.Lines.Add('------------------------------------------');

// Te puede devolver N autorizaciones (accedo directamente a la primera)
s := 'Autorizacion: ' + sLineBreak +
'Estado: ' + r.autorizaciones[0].estado + sLineBreak +
'Número: ' + r.autorizaciones[0].numeroAutorizacion + sLineBreak +
// 'Fecha: ' + r.autorizaciones[0].fechaAutorizacion.ToString + sLineBreak + // nil
'Comprobante: ' + r.autorizaciones[0].comprobante + sLineBreak +
'Mensajes: ' + Length(r.autorizaciones[0].mensajes).ToString + sLineBreak;

Memo1.Lines.Add(s);
Memo1.Lines.Add('------------------------------------------');

// Igual que antes, accedo sólo al primer mensaje
s := 'Mensaje: ' + sLineBreak +
'Identificador: ' + r.autorizaciones[0].mensajes[0].identificador + sLineBreak +
'Mensaje: ' + r.autorizaciones[0].mensajes[0].mensaje + sLineBreak +
'Info adicional: ' + r.autorizaciones[0].mensajes[0].informacionAdicional + sLineBreak +
'Tipo: ' + r.autorizaciones[0].mensajes[0].tipo;

Memo1.Lines.Add(s);
Memo1.Lines.Add('------------------------------------------');

Con esta prueba (yo he utilizado una clave errónea), ya puedes comprobar que el WebService responde "cosas".
El resultado es este:

https://i.imgur.com/opmYgA4.png

Consultada: INCORRECTA - Comprobantes: - Autorizaciones: 1
------------------------------------------
Autorizacion:
Estado: RECHAZADA
Número:
Comprobante:
Mensajes: 1

------------------------------------------
Mensaje:
Identificador: 80
Mensaje: ERROR EN LA ESTRUCTURA DE LA CLAVE DE ACCESO
Info adicional:
Tipo:
------------------------------------------

IVAND
26-07-2022, 21:37:35
Hola Neftali , muy agradecido por tu tiempo , te comento que puse a funcionar lo qye me indicas pero me sale un error, envio la clave

0107202201189171808600120011000000024581234567815

r := GetAutorizacionComprobantesOffline.autorizacionComprobante('0107202201099286992500120010020000056610 000566113');
Aqui da el error


First chance exception at $75404402. Exception class EDOMParseError with message 'End tag 'body' does not match the start tag 'br'.

Line: 1
<html><head><
title>Request Rejected</tit'. Process soap.exe (12132)


Estoy seguro que me falta algo en algun parametro antes de leer el webservice , yo se que tu tiempo es valioso pero si puedes darme una mano o una guia de agradeceria mucho

Este servicio lo que me retorna es un archivo xml que debo guardarlo en el disco de mi equipo para luego parsearlo y tomar la informacion que hay dentro

IVAND
27-07-2022, 04:45:32
Nota Importante he buscado en foros y aqui tengo algo q han echo en vfp, pero no se donde colocar este codigo en delphi 2009 para q no me marque el error

*-- Crea la estructura que debe tener un requerimiento (REQUEST) de un comprobante firmado del SRI.
PROCEDURE crearrequest_comprobante
LPARAMETERS vMensaje
TEXT TO sXMLRequest TEXTMERGE NOSHOW PRETEXT 7
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<validarComprobante xmlns="http://ec.gob.sri.ws.recepcion">
<xml xmlns=""><<vMensaje>></xml>
</validarComprobante>
</soap:Body>
</soap:Envelope>
ENDTEXT
RETURN sXMLRequest

ENDPROC

Pero no se como ponerlo ni donde ponerlo en delphi al parecer esto es lo que me esta faltando para poder descargar el archivo xml

Neftali [Germán.Estévez]
27-07-2022, 09:13:38
Pues no se Iván, ejecuta paso a paso a ver en qué línea falla.
A mi, con el dato que has puesto me funciona correctamente y me devuelve 1 autorización:

------------------------------------------------------------------------------
Consultada: 0107202201189171808600120011000000024581234567815 - Comprobantes: 1 - Autorizaciones: 1
------------------------------------------
Autorizacion:
Estado: AUTORIZADO
Número: 0107202201189171808600120011000000024581234567815
Comprobante: <?xml version="1.0" encoding="UTF-8"?><factura id="comprobante" version="2.1.0">
<infoTributaria>
<ambiente>2</ambiente>
<tipoEmision>1</tipoEmision>
<razonSocial>Baldoré Cía. Ltda.</razonSocial>
<nombreComercial>Baldoré Cía. Ltda.</nombreComercial>
<ruc>1891718086001</ruc>
<claveAcceso>0107202201189171808600120011000000024581234567815</claveAcceso>
<codDoc>01</codDoc>
<estab>001</estab>
<ptoEmi>100</ptoEmi>
<secuencial>000002458</secuencial>
<dirMatriz>Patate Sector Pitula</dirMatriz>
</infoTributaria>
<infoFactura>
<fechaEmision>01/07/2022</fechaEmision>
<dirEstablecimiento>Patate Sector Pitula</dirEstablecimiento>
<contribuyenteEspecial>00011</contribuyenteEspecial>
<obligadoContabilidad>SI</obligadoContabilidad>
<tipoIdentificacionComprador>04</tipoIdentificacionComprador>
<razonSocialComprador>COMERCIAL CASANOVA COMCASANOVA S.A.</razonSocialComprador>
<identificacionComprador>1391871473001</identificacionComprador>
<direccionComprador>CÓRDOVA S/N Y QUITO Y ALAJUELA</direccionComprador>
<totalSinImpuestos>7108.50</totalSinImpuestos>
<totalDescuento>0</totalDescuento>
<totalConImpuestos>
<totalImpuesto>
<codigo>2</codigo>
<codigoPorcentaje>2</codigoPorcentaje>
<baseImponible>11608.50</baseImponible>
<valor>1393.02</valor>
</totalImpuesto>
<totalImpuesto>
<codigo>3</codigo>
<codigoPorcentaje>3031</codigoPorcentaje>
<baseImponible>7108.50</baseImponible>
<valor>4500.00</valor>
</totalImpuesto>
</totalConImpuestos>
<propina>0</propina>
<importeTotal>13001.52</importeTotal>
<moneda>Dólar EE.UU.</moneda>
<pagos>
<pago>
<formaPago>20</formaPago>
<total>13001.52</total>
<plazo>60</plazo>
<unidadTiempo>Dias</unidadTiempo>
</pago>
</pagos>
</infoFactura>
<detalles>
<detalle>
<codigoPrincipal>PT-050709004</codigoPrincipal>
<codigoAuxiliar>1003995</codigoAuxiliar>
<descripcion>Bebida alcohólica sabor a whisky MrAllen Green 1000ml</descripcion>
<cantidad>3000.00</cantidad>
<precioUnitario>2.36950</precioUnitario>
<descuento>0.00</descuento>
<precioTotalSinImpuesto>7108.50</precioTotalSinImpuesto>
<impuestos>
<impuesto>
<codigo>2</codigo>
<codigoPorcentaje>2</codigoPorcentaje>
<tarifa>12</tarifa>
<baseImponible>11608.50</baseImponible>
<valor>853.02</valor>
</impuesto>
<impuesto>
<codigo>3</codigo>
<codigoPorcentaje>3031</codigoPorcentaje>
<tarifa>0</tarifa>
<baseImponible>7108.50</baseImponible>
<valor>4500.00</valor>
</impuesto>
</impuestos>
</detalle>
</detalles>
<infoAdicional>
<campoAdicional nombre="Direccion">CÓRDOVA S/N Y QUITO Y ALAJUELA</campoAdicional>
<campoAdicional nombre="Telefono">ND</campoAdicional>
<campoAdicional nombre="Email">contabilidad@comercialcasanova.com</campoAdicional>
<campoAdicional nombre="OrdenVenta">54911</campoAdicional>
<campoAdicional nombre="Descuento">0</campoAdicional>
<campoAdicional nombre="DescuentoAdicional">0</campoAdicional>
</infoAdicional>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.3.2#" Id="Signature459835">
<ds:SignedInfo Id="Signature-SignedInfo800322">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference Id="SignedPropertiesID1023636" Type="http://uri.etsi.org/01903#SignedProperties" URI="#Signature459835-SignedProperties636115">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>VlELpSkSqL8VFxRw19sp363/oJ8=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#Certificate182855">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>CJolG86W++Q/T0T1CyDk6uCm6Ug=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="Reference-ID-277143" URI="#comprobante">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>aA1zKw0f6HN1lndwDMA4MFz97wY=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue Id="SignatureValue345980">
YwCV0fymtpqb7T9HW5A9v1VzQNc4B0GzYnjh4YoY7QXSciX6mRfE0tqY1jBTJkYnm/R8i8ZsRZbN
vQA7u8l7GokssNFKUU7HJi7JUILAI4NpBe4bbzymJQv2rSDulH80nhIsnIBbsBIniSucsKC50vNG
VEVTvFHoHaN7scU5GK8dttow4STJsBNLTOmO8Xc2513M78o/wHfzpc9hGmcMuWvBjcGSTHnp21jj
DM1QJU+dWIOe+4JiEU5FPN/6lNFt/3V6qYEkCke8++yZx5w6rS6z3G2ZZboxc5LNc0n0iy5oNhwh
bOBlRVtnjMUTsQTL3iNIoOp91mPJisfEBlAWwg==
</ds:SignatureValue>
<ds:KeyInfo Id="Certificate182855">
<ds:X509Data>
<ds:X509Certificate>
MIIL9TCCCd2gAwIBAgIEFWniaTANBgkqhkiG9w0BAQsFADCBmTELMAkGA1UEBhMCRUMxHTAbBgNV
BAoMFFNFQ1VSSVRZIERBVEEgUy5BLiAyMTAwLgYDVQQLDCdFTlRJREFEIERFIENFUlRJRklDQUNJ
T04gREUgSU5GT1JNQUNJT04xOTA3BgNVBAMMMEFVVE9SSURBRCBERSBDRVJ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vgj7ppDv2Ef1fEC1zxZQLQ1
rZGZtSdNDMWGRbWxvyPecDhwvRuh43TpOZYZ0w==
</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
<ds:Object Id="Signature459835-Object800688"><etsi:QualifyingProperties Target="#Signature459835"><etsi:SignedProperties Id="Signature459835-SignedProperties636115"><etsi:SignedSignatureProperties><etsi:SigningTime>2022-07-01T20:34:37-05:00</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>Er5AA91iKGGgbL3HQEzuc8mx9ss=</ds:DigestValue></etsi:CertDigest><etsi:IssuerSerial><ds:X509IssuerName>CN=AUTORIDAD DE CERTIFICACION SUBCA-2 SECURITY DATA,OU=ENTIDAD DE CERTIFICACION DE INFORMACION,O=SECURITY DATA S.A. 2,C=EC</ds:X509IssuerName><ds:X509SerialNumber>359260777</ds:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#Reference-ID-277143"><etsi:Description>contenido comprobante</etsi:Description><etsi:MimeType>text/xml</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></ds:Object></ds:Signature></factura>
Mensajes: 0
------------------------------------------

¿Con qué versión de Delphi trabajas? Yo lo he probado con la 11.
De todas formas, te adjunto el proyecto y lo intentas revisar.

Neftali [Germán.Estévez]
27-07-2022, 09:14:55
;547603']¿Con qué versión de Delphi trabajas? Yo lo he probado con la 11.


Con la 10.3 también me ha funcionado correctamente y devuelve 1 autorización.

IVAND
27-07-2022, 18:37:12
No funciona , Al parecer es un tema de versiones en delphi 2009 creo q algunas cosas no estan implementadas para tratar estos servicios , como si estan en versiones superiores

Ya seguire intentando , Gracias por la ayuda Neftali

Compare las unidades y hay muchos metodos distintos entre una version y la otra

movorack
27-07-2022, 22:09:33
Sí, Es posible que en Delphi 2009 no estén algunas cosas implementadas, y que fueron corregidas o añadidas en versiones mas recientes.

Si tienes acceso a versiones mas recientes (Aunque igual lo podrías hacer en otro lenguaje), podrías hacer en esta versión una DLL (o BPL) que consuma el servicio y te entregue el resultado en el programa que compilas en Delphi 2009.

Neftali [Germán.Estévez]
28-07-2022, 08:56:07
No funciona , Al parecer es un tema de versiones en delphi 2009 creo q algunas cosas no estan implementadas para tratar estos servicios , como si estan en versiones superiores


Entiendo que la versión que yo te pasé no te compila con 2009.
¿Puedes arreglarla para que compile con tu versión o los errores son insalvables?

IVAND
14-09-2022, 02:28:55
Hola a todos mil disculpas por el retraso de mis agradecimientos por su ayuda ,

No puedo leer en delphi 2009 , me he bajado delphi rad studio 11 , y anda perfecto , ahora otra ayuda mas como puedo leer la informacion que me retorna , es decir este xml quiero leer sus nodos y poder insertar en mi base de datos


Gracias por su ayuda

IVAND
14-09-2022, 16:38:17
Voy a ponerme a averiguar sobre parsear el xml cualquier duda les molesto , gracias y si alguien me puede ayudar como siempre les quedo agradecido


con delphi 2009 no se puede hacer tan sencillo , pero igual voy a seguir revisando pues seria fantastico hacerlo directo en delphi 2009

IVAND
14-09-2022, 16:39:49
;547632']Entiendo que la versión que yo te pasé no te compila con 2009.
¿Puedes arreglarla para que compile con tu versión o los errores son insalvables?

Si compila con algunos cambios , pero da error al llamar al servicio

egostar
15-09-2022, 01:09:21
....
con delphi 2009 no se puede hacer tan sencillo , pero igual voy a seguir revisando pues seria fantastico hacerlo directo en delphi 2009

También puedes optar por crear una DLL con Delphi 11 que consuma los métodos y llamarla desde Delphi 2009 para obtener el RESPONSE.

Saludos