1

En el trabajo me pidieron como mi primera app, para empezar

con un usuario y contraseña que use como header en mi código, mas su url, params, cookies.

me da este json:

    {
        "03_011A_DATAREQ": {
            "tableId": "F03B11",
            "rowset": [
                {
                    "NRO_INTERNO": "2",
                    "TIPO_INTERNO": "FA",
                    "FECHA_FACTURA": "06/03/2019",
                    "MONTO": 6050,
                    "FECHA_VENCIMIENTO": "11/07/2019",
                    "NRO_LEGAL": "001A0000100000007"
                },
                {
                    "NRO_INTERNO": "1",
                    "TIPO_INTERNO": "FA",
                    "FECHA_FACTURA": "06/21/2019",
                    "MONTO": 3509,
                    "FECHA_VENCIMIENTO": "21/07/2019",
                    "NRO_LEGAL": "001A0000100000006"
                }
        }
    }

Con su link :

http://qcsys.servehttp.com:922/jderest/v3/orchestrator/03_011A_ORCH?Cliente=80003

y params:

params

Cree un proyecto en Android:

main activity`public class MainActivity extends AppCompatActivity {


    private TextView textViewResult;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textViewResult = findViewById(R.id.text_view_result);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://qcsys.servehttp.com:922/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        JsonPlaceHolderApi jsonPlaceHolderApi = retrofit.create(JsonPlaceHolderApi.class);




        Call<List<Post>> call = jsonPlaceHolderApi.getPosts("80003");
        call.enqueue(new Callback<List<Post>>() {
            @Override
            public void onResponse(Call<List<Post>> call, Response<List<Post>> response) {
                if (!response.isSuccessful()) {
                    textViewResult.setText("Code: " + response.code());
                    return;
                }
                List<Post> posts = response.body();
                for (Post post : posts) {
                    String content = "";
                    content += "03_011A_DATAREQ: " + post.get03011aDatareq() + "\n";

                    textViewResult.append(content);

                }


            }
            @Override
            public void onFailure(Call<List<Post>> call, Throwable t) {
                textViewResult.setText(t.getMessage());
            }
        });
    }



}

interface

public interface JsonPlaceHolderApi {

    @Headers({"Content-Type:application/json;charset=UTF-8",
            "Accept:application/json",
            "Cookie:JSESSIONID=fYAV2KfouyICoHiKGuJ5n_-Q0kQOc-KNl6HmFk9Ce8K5JQtuMa7A!-530853743",
            "Authorization:Basic xxxxxxxxxxxxxxxxx" })
    @GET("jderest/v3/orchestrator/03_011A_ORCH")

    Call<List<Post>> getPosts( @Query("Cliente") String cliente);

y sus clases donde se encuentran los datos del postman

    public class Post {

    @SerializedName("03_011A_DATAREQ")
    @Expose
    private com.example.getquantum._03011aDatareq _03011aDatareq;

    public com.example.getquantum._03011aDatareq get03011aDatareq() {
        return _03011aDatareq;
    }

    public void set03011aDatareq(com.example.getquantum._03011aDatareq _03011aDatareq) {
        this._03011aDatareq = _03011aDatareq;
    }




}

    public class _03011aDatareq {

    @SerializedName("tableId")
    @Expose
    private String tableId;
    @SerializedName("rowset")
    @Expose
    private List<Rowset> rowset = null;
    @SerializedName("records")
    @Expose
    private Integer records;
    @SerializedName("moreRecords")
    @Expose
    private Boolean moreRecords;

    public String getTableId() {
        return tableId;
    }

    public void setTableId(String tableId) {
        this.tableId = tableId;
    }

    public List<Rowset> getRowset() {
        return rowset;
    }

    public void setRowset(List<Rowset> rowset) {
        this.rowset = rowset;
    }

    public Integer getRecords() {
        return records;
    }

    public void setRecords(Integer records) {
        this.records = records;
    }

    public Boolean getMoreRecords() {
        return moreRecords;
    }

    public void setMoreRecords(Boolean moreRecords) {
        this.moreRecords = moreRecords;
    }



}

    public class Rowset {

    @SerializedName("NRO_INTERNO")
    @Expose
    private String nroInterno;
    @SerializedName("TIPO_INTERNO")
    @Expose
    private String tipoInterno;
    @SerializedName("FECHA_FACTURA")
    @Expose
    private String fechaFactura;
    @SerializedName("MONTO")
    @Expose
    private Integer monto;
    @SerializedName("FECHA_VENCIMIENTO")
    @Expose
    private String fechaVencimiento;
    @SerializedName("NRO_LEGAL")
    @Expose
    private String nroLegal;

    public String getNroInterno() {
        return nroInterno;
    }

    public void setNroInterno(String nroInterno) {
        this.nroInterno = nroInterno;
    }

    public String getTipoInterno() {
        return tipoInterno;
    }

    public void setTipoInterno(String tipoInterno) {
        this.tipoInterno = tipoInterno;
    }

    public String getFechaFactura() {
        return fechaFactura;
    }

    public void setFechaFactura(String fechaFactura) {
        this.fechaFactura = fechaFactura;
    }

    public Integer getMonto() {
        return monto;
    }

    public void setMonto(Integer monto) {
        this.monto = monto;
    }

    public String getFechaVencimiento() {
        return fechaVencimiento;
    }

    public void setFechaVencimiento(String fechaVencimiento) {
        this.fechaVencimiento = fechaVencimiento;
    }

    public String getNroLegal() {
        return nroLegal;
    }

    public void setNroLegal(String nroLegal) {
        this.nroLegal = nroLegal;
    }


    @Override
    public String toString(){
        return "03_011A_DATAREQ{" +
                "NRO_INTERNO" +  nroInterno + "\n" +
                "TIPO_INTERNO" + tipoInterno + "\n" +
                "FECHA_FACTURA" + fechaFactura + "\n" +
                "MONTO" + monto + "\n" +
                "FECHA_VENCIMIENTO" + fechaVencimiento + "\n" +
                "NRO_LEGAL" + nroLegal;



    }

me he basado en muchos vídeos de youtube, google y foros de acá, pero no me funciona. ¿Hay algo en que este fallando?

!muchas gracias!

1 respuesta 1

0
  Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://qcsys.servehttp.com:922/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();

Estas intentando acceder a través de https desde la aplicación. Al parecer ese servidor no soporta https. Simplemente elimina la s de https

Analizando los paquetes de la red. el servidor no responde el handshake (apretón de manos), esto es necesario para establecer una conexión segura (Client Hello, Server hello).

Fíjate en el tiempo del paquete número 17 y el número 84. pasan 30 segundos aproximadamente y el cliente cierra la conexión por tiempo agotado (timeout) ya que el servidor no responde con un Server hello.

1
  • Muchas gracias! Se solucionó el problema quitando la S!
    – G. Capovi
    el 25 jun. 2021 a las 1:30

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.