package com.fp.webservices.snap.seguridad;

import ec.gob.registrocivil.consultacedula.Cedula;
import ec.gob.registrocivil.consultacedula.WSRegistroCivilConsultaCedula;
import ec.gob.registrocivil.consultacedula.WSRegistroCivilConsultaCedula_Service;
import javax.xml.ws.handler.HandlerResolver;

public class RegistroCivilClient {

    public static void main(String[] args) {

        PermissionClient permissionClient = new PermissionClient("https://www.bsg.gob.ec/sw/RC/BSGSW01_Consultar_Cedula?wsdl");

        try {
            DatosHeader headers = new DatosHeader();
            headers = permissionClient.generaToken();
            WSRegistroCivilConsultaCedula_Service service = new WSRegistroCivilConsultaCedula_Service();

            HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver(headers);
            service.setHandlerResolver((HandlerResolver) handlerResolver);

            WSRegistroCivilConsultaCedula port = service.getWSRegistroCivilConsultaCedulaPort();
            System.out.println("  ---  >> >");
            String cedula = "1001114840";
            String usuario = "testroot";
            String contrasenia = "Sti1DigS21";
            Cedula result = port.busquedaPorCedula(cedula, usuario, contrasenia);
            System.out.println("Result = " + result.getNombre());

        } catch (Exception ex) {

            System.out.println("  --> " + ex.getMessage());
            ex.printStackTrace();
        }
    }
}
