Получить xml список возвращает null retrofit2 Android - PullRequest
0 голосов
/ 20 апреля 2020

Мне уже удалось заставить его принести 1 требование, но когда я привожу список xml, он возвращает мне ноль, и я не знаю, как это сделать. Мне нужно вернуть все 'Description'

 <ArrayOfVariableRow xmlns="http://schemas.datacntract.org/2004/07/Prys" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <VariableRow>
            <Description>Agencia0001</Description>
            <FullDescription>App/Agencia0001</FullDescription>
            <Id>4101</Id>
            <Name>App.AGENCIA0001</Name>
 </VariableRow>
        <VariableRow>
            <Description>Agencia0001</Description>
            <FullDescription>App/Agencia0001</FullDescription>
            <Id>4101</Id>
            <Name>App.AGENCIA0001</Name>
 </VariableRow>
    </ArrayOfVariableRow>

Класс GetNameButtons

package com.anyvision.facekeyexample.models;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementArray;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Path;
import org.simpleframework.xml.Root;

@Root(name="ArrayOfVariableRow", strict=false)
public class GetNameButtons {

@Element(name="Description")
@Path("VariableRow")
private String nmButtonAgencia;

    @ElementList(name="VariableRow")
    @Path("ArrayOfVariableRow")
    private List<DescriptionsAgencia> articleList;


    public String getButtonAgencia() {
        return nmButtonAgencia;
    }

    public List<DescriptionsAgencia> getArticleList() {
        return articleList;
    }
}

Описание класса

  1. пакет com.anyvision.facekeyexample. модели; import org.simpleframework. xml .Element; import org.simpleframework. xml .Root;

    @Root(name="VariableRow", strict=false)
    public class DescriptionsAgencia {
    
        @Element(name="Description")
        private String description;
    
        public String getDescription(){
            return description;
        }
    }
    

Модификация

public void GetVariablesByFilter(final String SessionID) {
        setServerLocalUrl(GetVariables.getInstance().getServerUrl());

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(serverLocalUrl)
                .addConverterFactory(SimpleXmlConverterFactory.create())
                .build();
        AuthToken tokenAuth = retrofit.create(AuthToken.class);

        Call<GetNameButtons> call = tokenAuth.GetVariableAgencia(SessionID);

        call.enqueue(new Callback<GetNameButtons>() {
            //@RequiresApi(api = Build.VERSION_CODES.N)
            @Override
            public void onResponse(Call<GetNameButtons> call, Response<GetNameButtons> response) {

                if (response.isSuccessful()) {
                    //GetNameButtons nmButton = response.body();

                    Log.d("auth", response.toString());
                    Log.d("auth", response.message());
                    Log.d("auth", response.body().toString());

                } else {
                    Log.d("auth", response.errorBody().toString());
                }
            }

            @Override
            public void onFailure(Call<GetNameButtons> call, Throwable t) {
                Log.d("auth", t.getMessage());
            }
        });
    }

Класс Auth

Call<GetNameButtons> GetVariableAgencia(@Header("SessionID") String SessionID);

Я уже тестирую это в почтальоне и приносит то, что мне нужно, но здесь, в коде, он возвращает мне ноль. пожалуйста, спасибо за помощь.

...