Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Obtener fecha de un web service soap (https://www.clubdelphi.com/foros/showthread.php?t=94987)

lbidi 14-12-2020 23:42:07

Obtener fecha de un web service soap
 
Estimados.. Recurro a uds luego de un dia tratando de encontrar el problema( pero en realidad, el problema soy yo, que no se aun utilizar muy bien las clases y los web services ).
Necesito obtener una fecha resultado del wbs que presento a continuacion.

El problema es que no estoy muy seguro como instanciarlo, ejecutarlo y obtener el resultado.

El wbs es el siguiente
Código Delphi [-]
unit u_ws_ultimo_cierre;

interface

uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;

const
  IS_NLBL = $0004;
  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 Embarcadero types; however, they could also 
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:date            - "http://www.w3.org/2001/XMLSchema"[Gbl]

  wsultimocierre_Execute = class;               { "Cotiza"[Lit][GblElm] }
  wsultimocierre_ExecuteResponse = class;       { "Cotiza"[Lit][GblElm] }
  wsultimocierreout    = class;                 { "Cotiza"[GblCplx] }



  // ************************************************************************ //
  // XML       : wsultimocierre.Execute, global, 
  // Namespace : Cotiza
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  wsultimocierre_Execute = class(TRemotable)
  private
  public
    constructor Create; override;
  published
  end;



  // ************************************************************************ //
  // XML       : wsultimocierre.ExecuteResponse, global, 
  // Namespace : Cotiza
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  wsultimocierre_ExecuteResponse = class(TRemotable)
  private
    FSalida: wsultimocierreout;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Salida: wsultimocierreout  read FSalida write FSalida;
  end;



  // ************************************************************************ //
  // XML       : wsultimocierreout, global, 
  // Namespace : Cotiza
  // ************************************************************************ //
  wsultimocierreout = class(TRemotable)
  private
    FFecha: TXSDate;
  public
    destructor Destroy; override;
  published
    property Fecha: TXSDate  Index (IS_NLBL) read FFecha write FFecha;
  end;


  // ************************************************************************ //
  // Namespace : Cotiza
  // soapAction: Cotizaaction/AWSULTIMOCIERRE.Execute
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : wsultimocierreSoapBinding
  // service   : wsultimocierre
  // port      : wsultimocierreSoapPort
  // URL       : https://cotizaciones.bcu.gub.uy/wsco...wsultimocierre
  // ************************************************************************ //
  wsultimocierreSoapPort = interface(IInvokable)
  ['{1F3D904F-D18B-D7CE-768C-C23931858A2E}']

    // Cannot unwrap: 
    //     - Input element wrapper name does not match operation's name
    function Execute(const parameters: wsultimocierre_Execute): wsultimocierre_ExecuteResponse; stdcall;

  end;

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


implementation
  uses System.SysUtils;

function GetwsultimocierreSoapPort(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): wsultimocierreSoapPort;
const
  defWSDL = 'https://cotizaciones.bcu.gub.uy/wscotizaciones/servlet/awsultimocierre?wsdl';
  defURL  = 'https://cotizaciones.bcu.gub.uy/wscotizaciones/servlet/awsultimocierre';
  defSvc  = 'wsultimocierre';
  defPrt  = 'wsultimocierreSoapPort';
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 wsultimocierreSoapPort);
    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;


constructor wsultimocierre_Execute.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

constructor wsultimocierre_ExecuteResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor wsultimocierre_ExecuteResponse.Destroy;
begin
  System.SysUtils.FreeAndNil(FSalida);
  inherited Destroy;
end;

destructor wsultimocierreout.Destroy;
begin
  System.SysUtils.FreeAndNil(FFecha);
  inherited Destroy;
end;

initialization
  { wsultimocierreSoapPort }
  InvRegistry.RegisterInterface(TypeInfo(wsultimocierreSoapPort), 'Cotiza', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(wsultimocierreSoapPort), 'Cotizaaction/AWSULTIMOCIERRE.Execute');
  InvRegistry.RegisterInvokeOptions(TypeInfo(wsultimocierreSoapPort), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(wsultimocierreSoapPort), ioLiteral);
  RemClassRegistry.RegisterXSClass(wsultimocierre_Execute, 'Cotiza', 'wsultimocierre_Execute', 'wsultimocierre.Execute');
  RemClassRegistry.RegisterSerializeOptions(wsultimocierre_Execute, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(wsultimocierre_ExecuteResponse, 'Cotiza', 'wsultimocierre_ExecuteResponse', 'wsultimocierre.ExecuteResponse');
  RemClassRegistry.RegisterSerializeOptions(wsultimocierre_ExecuteResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(wsultimocierreout, 'Cotiza', 'wsultimocierreout');

end.

Y lo tengo "instanciado" en mi aplicacion de esta manera.

Código Delphi [-]
    dFecha : TDate;
    ws_cierre : wsultimocierreSoapPort;
    ws_cierre := GetwsultimocierreSoapPort;
//    dFecha := ??????

Muchas gracias de antemano por su colabaracion..

Saludos

ElKurgan 15-12-2020 08:28:43

Hola, Ibidi.

Lo primero que tienes que hacer es definir la fecha correctamente. Como en el web service está definida asi:

Código Delphi [-]
 wsultimocierreout = class(TRemotable)
  private
    FFecha: TXSDate;
  public
    destructor Destroy; override;
  published
    property Fecha: TXSDate  Index (IS_NLBL) read FFecha write FFecha;
  end;

Tendrás que definirla en Delphi también como:

Código Delphi [-]
dFecha : TXSDate;

Ahora bien, GetwsultimocierreSoapPort devuelve un wsultimocierreSoapPort (tu variable ws_cierre) que tiene una función execute, con un parámetro de tipo wsultimocierre_Execute, que devuelve un tipo wsultimocierre_ExecuteResponse, que tiene una propiedad Salida de tipo wsultimocierreout y este a su vez es el que tiene la propiedad Fecha, creo que al final debería ser más o menos así:

Código Delphi [-]
var
  dFecha : TXSDate;
  ws_cierre : wsultimocierreSoapPort;
  ws_cierre_exe: wsultimocierre_Execute;
  ws_cierre_resp: wsultimocierre_ExecuteResponse;
  ws_ultimo_cierre: wsultimocierreout ;
..
..
  ws_cierre := GetwsultimocierreSoapPort;
  ws_cierre_exe := wsultimocierre_Execute.Create;
  ws_cierre_resp := ws_cierre.Execute(ws_cierre_Exe);
  ws_ultimo_cierre := ws_cierre_resp.Salida;

  dFecha := ws_ultimo_cierre.Fecha;

Creo que más o menos sería así, pero tengo algo oxidado el acceso a webservices en Delphi (como otros muchos males del mundo, ahora estoy con Java por necesidad), pero creo que puede orientarte un poco

Saludos

Neftali [Germán.Estévez] 15-12-2020 10:24:34

Un código como este debería ser suficiente:

Código Delphi [-]
var
  ws_cierre:    wsultimocierreSoapPort;
  ws_out:       wsultimocierreout;
begin
  ws_cierre := GetwsultimocierreSoapPort;
  ws_out := ws_cierre.Execute(wsultimocierre_Execute.Create).Salida;
  ShowMessage('Último cierre: ' + DateToStr(ws_out.Fecha.AsDate));



El tipo TXSDate está defindo en la unit Soap.XSBuiltIns
http://docwiki.embarcadero.com/Libra...iltIns.TXSDate

lbidi 15-12-2020 15:41:47

MUCHISIMAS GRACIAS a ambos !!

Funciono perfecto de ambas maneras.

Ahora sigo en otra pregunta , porque van ambas concatenadas.

lbidi 15-12-2020 15:45:43

Luego de obtener esa fecha, debo llamar a otro ws que sigue a continuacion. Es para obtener cotizaciones de las monedas extranjeras a esa fecha.
Me interesa solo la cotizacion del Dolar, pero no me doy cuenta si hay que pasarle algo como parametro ( y como ), o si retorna todas las monedas que retorna el ws.

Muchisimas gracias.. me salvan la vida...

El codigo del ws es este.

Código Delphi [-]
unit u_ws_cotizaciones;

interface

uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_NLBL = $0004;
  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 Embarcadero 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]
  // !:double          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:date            - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:short           - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:byte            - "http://www.w3.org/2001/XMLSchema"[Gbl]

  wsbcucotizaciones_ExecuteResponse = class;    { "Cotiza"[Lit][GblElm] }
  wsbcucotizaciones_Execute = class;            { "Cotiza"[Lit][GblElm] }
  wsbcucotizacionesout = class;                 { "Cotiza"[GblCplx] }
  wsbcucotizacionesin  = class;                 { "Cotiza"[GblCplx] }
  respuestastatus      = class;                 { "Cotiza"[GblCplx] }
  datoscotizaciones_dato = class;               { "Cotiza"[GblCplx] }

  datoscotizaciones = array of datoscotizaciones_dato;   { "Cotiza"[GblCplx] }


  // ************************************************************************ //
  // XML       : wsbcucotizaciones.ExecuteResponse, global, 
  // Namespace : Cotiza
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  wsbcucotizaciones_ExecuteResponse = class(TRemotable)
  private
    FSalida: wsbcucotizacionesout;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Salida: wsbcucotizacionesout  read FSalida write FSalida;
  end;



  // ************************************************************************ //
  // XML       : wsbcucotizaciones.Execute, global, 
  // Namespace : Cotiza
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  wsbcucotizaciones_Execute = class(TRemotable)
  private
    FEntrada: wsbcucotizacionesin;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Entrada: wsbcucotizacionesin  read FEntrada write FEntrada;
  end;



  // ************************************************************************ //
  // XML       : wsbcucotizacionesout, global, 
  // Namespace : Cotiza
  // ************************************************************************ //
  wsbcucotizacionesout = class(TRemotable)
  private
    Frespuestastatus: respuestastatus;
    Fdatoscotizaciones: datoscotizaciones;
  public
    destructor Destroy; override;
  published
    property respuestastatus:   respuestastatus    read Frespuestastatus write Frespuestastatus;
    property datoscotizaciones: datoscotizaciones  read Fdatoscotizaciones write Fdatoscotizaciones;
  end;

  ArrayOfint = array of SmallInt;               { "Cotiza"[GblCplx] }


  // ************************************************************************ //
  // XML       : wsbcucotizacionesin, global, 
  // Namespace : Cotiza
  // ************************************************************************ //
  wsbcucotizacionesin = class(TRemotable)
  private
    FMoneda: ArrayOfint;
    FFechaDesde: TXSDate;
    FFechaHasta: TXSDate;
    FGrupo: ShortInt;
  public
    destructor Destroy; override;
  published
    property Moneda:     ArrayOfint  read FMoneda write FMoneda;
    property FechaDesde: TXSDate     Index (IS_NLBL) read FFechaDesde write FFechaDesde;
    property FechaHasta: TXSDate     Index (IS_NLBL) read FFechaHasta write FFechaHasta;
    property Grupo:      ShortInt    read FGrupo write FGrupo;
  end;



  // ************************************************************************ //
  // XML       : respuestastatus, global, 
  // Namespace : Cotiza
  // ************************************************************************ //
  respuestastatus = class(TRemotable)
  private
    Fstatus: ShortInt;
    Fcodigoerror: SmallInt;
    Fmensaje: string;
  published
    property status:      ShortInt  read Fstatus write Fstatus;
    property codigoerror: SmallInt  read Fcodigoerror write Fcodigoerror;
    property mensaje:     string    read Fmensaje write Fmensaje;
  end;



  // ************************************************************************ //
  // XML       : datoscotizaciones.dato, global, 
  // Namespace : Cotiza
  // ************************************************************************ //
  datoscotizaciones_dato = class(TRemotable)
  private
    FFecha: TXSDate;
    FMoneda: SmallInt;
    FNombre: string;
    FCodigoISO: string;
    FEmisor: string;
    FTCC: Double;
    FTCV: Double;
    FArbAct: Double;
    FFormaArbitrar: ShortInt;
  public
    destructor Destroy; override;
  published
    property Fecha:         TXSDate   Index (IS_NLBL) read FFecha write FFecha;
    property Moneda:        SmallInt  read FMoneda write FMoneda;
    property Nombre:        string    read FNombre write FNombre;
    property CodigoISO:     string    read FCodigoISO write FCodigoISO;
    property Emisor:        string    read FEmisor write FEmisor;
    property TCC:           Double    read FTCC write FTCC;
    property TCV:           Double    read FTCV write FTCV;
    property ArbAct:        Double    read FArbAct write FArbAct;
    property FormaArbitrar: ShortInt  read FFormaArbitrar write FFormaArbitrar;
  end;


  // ************************************************************************ //
  // Namespace : Cotiza
  // soapAction: Cotizaaction/AWSBCUCOTIZACIONES.Execute
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : wsbcucotizacionesSoapBinding
  // service   : wsbcucotizaciones
  // port      : wsbcucotizacionesSoapPort
  // URL       : https://cotizaciones.bcu.gub.uy/wsco...cucotizaciones
  // ************************************************************************ //
  wsbcucotizacionesSoapPort = interface(IInvokable)
  ['{FB29A9D1-0AD1-E614-EF96-5E020C189B50}']

    // Cannot unwrap: 
    //     - Input element wrapper name does not match operation's name
    function  Execute(const parameters: wsbcucotizaciones_Execute): wsbcucotizaciones_ExecuteResponse; stdcall;
  end;

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


implementation
  uses System.SysUtils;

function GetwsbcucotizacionesSoapPort(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): wsbcucotizacionesSoapPort;
const
  defWSDL = 'https://cotizaciones.bcu.gub.uy/wscotizaciones/servlet/awsbcucotizaciones?wsdl';
  defURL  = 'https://cotizaciones.bcu.gub.uy/wscotizaciones/servlet/awsbcucotizaciones';
  defSvc  = 'wsbcucotizaciones';
  defPrt  = 'wsbcucotizacionesSoapPort';
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 wsbcucotizacionesSoapPort);
    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;


constructor wsbcucotizaciones_ExecuteResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor wsbcucotizaciones_ExecuteResponse.Destroy;
begin
  System.SysUtils.FreeAndNil(FSalida);
  inherited Destroy;
end;

constructor wsbcucotizaciones_Execute.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor wsbcucotizaciones_Execute.Destroy;
begin
  System.SysUtils.FreeAndNil(FEntrada);
  inherited Destroy;
end;

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

destructor wsbcucotizacionesin.Destroy;
begin
  System.SysUtils.FreeAndNil(FFechaDesde);
  System.SysUtils.FreeAndNil(FFechaHasta);
  inherited Destroy;
end;

destructor datoscotizaciones_dato.Destroy;
begin
  System.SysUtils.FreeAndNil(FFecha);
  inherited Destroy;
end;

initialization
  { wsbcucotizacionesSoapPort }
  InvRegistry.RegisterInterface(TypeInfo(wsbcucotizacionesSoapPort), 'Cotiza', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(wsbcucotizacionesSoapPort), 'Cotizaaction/AWSBCUCOTIZACIONES.Execute');
  InvRegistry.RegisterInvokeOptions(TypeInfo(wsbcucotizacionesSoapPort), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(wsbcucotizacionesSoapPort), ioLiteral);
  RemClassRegistry.RegisterXSInfo(TypeInfo(datoscotizaciones), 'Cotiza', 'datoscotizaciones');
  RemClassRegistry.RegisterXSClass(wsbcucotizaciones_ExecuteResponse, 'Cotiza', 'wsbcucotizaciones_ExecuteResponse', 'wsbcucotizaciones.ExecuteResponse');
  RemClassRegistry.RegisterSerializeOptions(wsbcucotizaciones_ExecuteResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(wsbcucotizaciones_Execute, 'Cotiza', 'wsbcucotizaciones_Execute', 'wsbcucotizaciones.Execute');
  RemClassRegistry.RegisterSerializeOptions(wsbcucotizaciones_Execute, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(wsbcucotizacionesout, 'Cotiza', 'wsbcucotizacionesout');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(wsbcucotizacionesout), 'datoscotizaciones', '[ArrayItemName="datoscotizaciones.dato"]');
  RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfint), 'Cotiza', 'ArrayOfint');
  RemClassRegistry.RegisterXSClass(wsbcucotizacionesin, 'Cotiza', 'wsbcucotizacionesin');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(wsbcucotizacionesin), 'Moneda', '[ArrayItemName="item"]');
  RemClassRegistry.RegisterXSClass(respuestastatus, 'Cotiza', 'respuestastatus');
  RemClassRegistry.RegisterXSClass(datoscotizaciones_dato, 'Cotiza', 'datoscotizaciones_dato', 'datoscotizaciones.dato');

end.

Neftali [Germán.Estévez] 16-12-2020 08:42:20

Revisando por encima, parece que wsbcucotizacionesin, debes asignarlo tú.
De todas formas, para no estar probando, deberías buscar si hay documentación.

lbidi 17-12-2020 15:50:08

Gracias German por responder. He estado buscando informacion pero al ser un organismo del estado, no esta tan facil de encontrar si hubiera, por eso
fue que puse el post original .

No tengo ni idea como hacer lo que me pides, pero ya vere.. habra que ir tanteando como se hace, a prueba y error.

Saludos

Neftali [Germán.Estévez] 18-12-2020 08:36:01

Cita:

Empezado por lbidi (Mensaje 539495)
No tengo ni idea como hacer lo que me pides, pero ya vere.. habra que ir tanteando como se hace, a prueba y error.

Al final debes llamar al Execute. A partir de ahí dsebes ir "tirando del hilo" como se suele decir.
El parámetro de entrada es de tipo wsbcucotizaciones_Execute y la salida de tipo wsbcucotizaciones_ExecuteResponse.

Si te centras en la respuesta, tiene una property:

Código Delphi [-]
property Salida: wsbcucotizacionesout  read FSalida write FSalida;

A su vez wsbcucotizacionesout tiene 2 propiedades:

Código Delphi [-]
    property respuestastatus:   respuestastatus    read Frespuestastatus write Frespuestastatus;
    property datoscotizaciones: datoscotizaciones  read Fdatoscotizaciones write Fdatoscotizaciones;


respuestastatus parece por el nombre cómo ha ido la petición y datoscotizaciones es un array del tipo datoscotizaciones_dato, que parece ser lo que tú necesitas:

Código Delphi [-]
    property Fecha:         TXSDate   Index (IS_NLBL) read FFecha write FFecha;
    property Moneda:        SmallInt  read FMoneda write FMoneda;
    property Nombre:        string    read FNombre write FNombre;
    property CodigoISO:     string    read FCodigoISO write FCodigoISO;
    property Emisor:        string    read FEmisor write FEmisor;
    property TCC:           Double    read FTCC write FTCC;
    property TCV:           Double    read FTCV write FTCV;
    property ArbAct:        Double    read FArbAct write FArbAct;
    property FormaArbitrar: ShortInt  read FFormaArbitrar write FFormaArbitrar;

Con el parámetro de entrada debes hacer lo mismo.
wsbcucotizaciones_Execute tiene una propiedad:

Código Delphi [-]
    property Entrada: wsbcucotizacionesin  read FEntrada write FEntrada;

Y el tipo wsbcucotizacionesin tiene la siguiente estructura:

Código Delphi [-]
    property Moneda:     ArrayOfint  read FMoneda write FMoneda;
    property FechaDesde: TXSDate     Index (IS_NLBL) read FFechaDesde write FFechaDesde;
    property FechaHasta: TXSDate     Index (IS_NLBL) read FFechaHasta write FFechaHasta;
    property Grupo:      ShortInt    read FGrupo write FGrupo;

Tiene sentido, que para solicittar una cotización debas añadir unas fechas y una moneda. El Grupo, ya no se que es.

Neftali [Germán.Estévez] 18-12-2020 09:12:43

No es muy complicado.
Un código como este conecta y devuelve resultados:

Código Delphi [-]
var
  wsSoapPort: wsbcucotizacionesSoapPort;
  ws_out: wsbcucotizacionesout;
  p: wsbcucotizaciones_Execute;
  Monedas: ArrayOfint;
begin
  wsSoapPort := GetwsbcucotizacionesSoapPort();

  p := wsbcucotizaciones_Execute.Create;
  p.Entrada := wsbcucotizacionesin.Create;
  p.Entrada.FechaDesde := TXSDate.Create;
  p.Entrada.FechaHasta := TXSDate.Create;

  SetLength(Monedas, 1);
  Monedas[0] := 2; // Monedas[2] := 1;

  p.Entrada.Moneda := Monedas;
  p.Entrada.FechaDesde.AsDate := EncodeDate(2020, 12, 01);
  p.Entrada.FechaHasta.AsDate := EncodeDate(2020, 12, 31);

  ws_out := wsSoapPort.Execute(p).Salida;

  ShowMessage('Respuesta: ' + IntToStr(ws_out.respuestastatus.status) + ' - ' +
              IntToStr(ws_out.respuestastatus.codigoerror) + ' - ' +
              ws_out.respuestastatus.mensaje);

  ShowMessage('Número de cotizaciones: ' + IntToStr(Length(ws_out.datoscotizaciones)));

  ShowMessage(
    'Nombre: ' + ws_out.datoscotizaciones[0].Nombre + sLineBreak +
    'CodigoISO: ' + ws_out.datoscotizaciones[0].CodigoISO + sLineBreak +
    'Emisor: ' + ws_out.datoscotizaciones[0].Emisor + sLineBreak +
    'Fecha: ' + DateToStr(ws_out.datoscotizaciones[0].Fecha.AsDate) + sLineBreak +
    'Modeda: ' + IntToStr(ws_out.datoscotizaciones[0].Moneda) + sLineBreak +
    'TCC: ' + FloatToStr(ws_out.datoscotizaciones[0].TCC) + sLineBreak +
    'TCC: ' + FloatToStr(ws_out.datoscotizaciones[0].TCV));

Un código como este devuelve algun resultado con sentido.



Si accedes a la primera:


ElKurgan 21-12-2020 07:16:40

Wow! Qué gran trabajo, Germán... Yo me había atorado un poco y está todo más que claro...

Gracias y un saludo

lbidi 21-12-2020 14:37:05

EXCELENTE es poco GERMAN...

Muchisimas gracias !!!

Soy bastante inutil y neofito con respecto a los webservices pero con ese nivel de detalle tuyo , es muy facil de comprender.

Mi mayor estimacion para ti y mi respeto.

Saludos y felicias fiestas ...

lbidi 04-01-2021 03:07:27

FELIZ AÑO PARA TODOS LOS FORISTAS !!!

Estimados, vuelvo a molestar para preguntar porque puede ser que estos webservices que tan bien German ayudo a que me funcionara,
no se ejecute bien en Windows 7 y funcione perfecto en WIN 10 ??

Solamente me dice que no se pudo establecer comunicacion con el servidor..

Neftali [Germán.Estévez] 11-01-2021 10:22:26

Me da la impresión de que tiene que ver con los protocolos de comunicación.
Lo primero es analizarlo utilizando la web: https://www.ssllabs.com/ssltest/

Accede a la web y analiza tu servidor: https://cotizaciones.bcu.gub.uy/wscotizaciones/servlet/

Luego, aplicando esto que tienes aquí, ya sea mediante los parches o creando las claves del registro, te debería funcionar.
Yo he conseguido que desaparezca el error y acced sin problemas.
https://support.microsoft.com/en-us/...rotocols-in-wi

Revisa también este bug. Ahí hay soluciones que te ayudarán:
https://quality.embarcadero.com/browse/RSP-31406

lbidi 19-01-2021 21:41:18

Muchas gracias German.

Aun no he podido probarlo en un pc con W7 pero apenas pueda, comento como me fue.

Saludos !!


La franja horaria es GMT +2. Ahora son las 07:20:57.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi