0

我为一个移动应用程序项目工作,并且在商店中使用代理检索信息时遇到问题。这是一个管理火车站的应用程序,对于一个火车站,我调用了一个 WebService 来检索接下来的 10 列火车(在 json 中)。

我有 2 节课,TrainStation(法语中的 Gare;))和 Train

Gare 中检索火车的方法:

getListTrains: function(TR3A) {
    console.log('plop');
    var trains = Ext.create('Ext.data.Store', {
        model: 'Train',
        proxy: {
            type: 'ajax',
            url: 'http://eclernet-mobile.dev.dsit-hp.sncf.fr/Trainservice.svc/GetListTrainsAtGare/'+TR3A,
            method: 'POST',
            headers: {
                'Accept': 'application/json'
            },
            reader: {
                type: 'json'
            }
        }
    });

    console.log(trains);
}

Train 类(将 Model 扩展为使用该方法):

Ext.define('Train', {
extend: 'Ext.data.Model',
config: {   
    codeMission: null,      
    numero:  null,
    sens: null,     
    dessertes: null,    
    voie: null,
    heureProbable: null,        
    heureTheorique: null,
    voiePrecedente: null,   
    quai: null,
    retard: null
},  


constructor: function(config) {
    this.initConfig(config);    
},  

});

当我使用有效的火车站调用我的方法时,我的 console.log(trains); 检索一个空对象...

我的 JSON:

[
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "VPL",
            "nom": "Villiers St Paul"
        },
        {
            "codeTR3A": "RIA",
            "nom": "Rieux Angicourt"
        },
        {
            "codeTR3A": "PXE",
            "nom": "Pont Ste Maxence"
        },
        {
            "codeTR3A": "CVE",
            "nom": "Chevrieres"
        },
        {
            "codeTR3A": "LUE",
            "nom": "Longueil Ste Marie"
        },
        {
            "codeTR3A": "LXS",
            "nom": "Le Meux La Croix"
        },
        {
            "codeTR3A": "CPE",
            "nom": "Compiegne"
        }
    ],
    "heureProbable": "02/08/2012 15:21",
    "heureTheorique": "02/08/2012 15:21",
    "numero": "847809",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 15:39",
    "heureTheorique": "02/08/2012 15:39",
    "numero": "847616",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "TOLI",
    "dessertes": [
        {
            "codeTR3A": "SLT",
            "nom": "St Leu d'Esserent"
        },
        {
            "codeTR3A": "PYO",
            "nom": "Précy sur Oise"
        },
        {
            "codeTR3A": "BRN",
            "nom": "Boran sur Oise"
        },
        {
            "codeTR3A": "BRK",
            "nom": "Bruyères sur Oise"
        },
        {
            "codeTR3A": "PEB",
            "nom": "Persan Beaumont"
        },
        {
            "codeTR3A": "CPO",
            "nom": "Champagne sur Oise"
        },
        {
            "codeTR3A": "IAP",
            "nom": "L'Isle Adam Parmain"
        },
        {
            "codeTR3A": "VMD",
            "nom": "Valmondois"
        },
        {
            "codeTR3A": "AUW",
            "nom": "Auvers sur Oise"
        },
        {
            "codeTR3A": "CPW",
            "nom": "Chaponval"
        },
        {
            "codeTR3A": "PPT",
            "nom": "Pont Petit"
        },
        {
            "codeTR3A": "EPL",
            "nom": "Epluches"
        },
        {
            "codeTR3A": "SOA",
            "nom": "St Ouen l'Aumone"
        },
        {
            "codeTR3A": "PSE",
            "nom": "Pontoise"
        }
    ],
    "heureProbable": "02/08/2012 15:54",
    "heureTheorique": "02/08/2012 15:54",
    "numero": "121038",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "ZUCO",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "BBN",
            "nom": "La Borne Blanche"
        },
        {
            "codeTR3A": "SUR",
            "nom": "Survilliers Fosses"
        },
        {
            "codeTR3A": "LOV",
            "nom": "Louvres"
        },
        {
            "codeTR3A": "LNX",
            "nom": "Les Noues"
        },
        {
            "codeTR3A": "GOU",
            "nom": "Goussainville"
        },
        {
            "codeTR3A": "VIB",
            "nom": "Villiers le Bel"
        },
        {
            "codeTR3A": "GAJ",
            "nom": "Garges Sarcelles"
        },
        {
            "codeTR3A": "PRF",
            "nom": "Pierrefitte Stains"
        },
        {
            "codeTR3A": "SDE",
            "nom": "St Denis"
        },
        {
            "codeTR3A": "SFD",
            "nom": "Stade de France St D"
        },
        {
            "codeTR3A": "GDS",
            "nom": "Paris Nord RER"
        },
        {
            "codeTR3A": "CLX",
            "nom": "Châtelet les Halles"
        },
        {
            "codeTR3A": "PAA",
            "nom": "Paris Lyon Banlieue"
        },
        {
            "codeTR3A": "MFA",
            "nom": "Maisons Alfort"
        },
        {
            "codeTR3A": "VSG",
            "nom": "Villeneuve S Georges"
        },
        {
            "codeTR3A": "KRW",
            "nom": "Montgeron Crosne"
        },
        {
            "codeTR3A": "YES",
            "nom": "Yerres"
        },
        {
            "codeTR3A": "BNY",
            "nom": "Brunoy"
        },
        {
            "codeTR3A": "BXI",
            "nom": "Boussy St Antoine"
        },
        {
            "codeTR3A": "CBV",
            "nom": "Combs la Ville"
        },
        {
            "codeTR3A": "LIU",
            "nom": "Lieusaint Moissy"
        },
        {
            "codeTR3A": "ZTN",
            "nom": "Savigny le Temple"
        },
        {
            "codeTR3A": "CES",
            "nom": "Cesson"
        },
        {
            "codeTR3A": "WEE",
            "nom": "Le Mée"
        },
        {
            "codeTR3A": "MEL",
            "nom": "Melun"
        }
    ],
    "heureProbable": "02/08/2012 15:59",
    "heureTheorique": "02/08/2012 15:59",
    "numero": "153260",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 16:07",
    "heureTheorique": "02/08/2012 16:07",
    "numero": "848522",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "2",
    "voiePrecedente": null
},
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "PXE",
            "nom": "Pont Ste Maxence"
        },
        {
            "codeTR3A": "CPE",
            "nom": "Compiegne"
        },
        {
            "codeTR3A": "NOY",
            "nom": "Noyon"
        },
        {
            "codeTR3A": "CNY",
            "nom": "Chauny"
        },
        {
            "codeTR3A": "TGR",
            "nom": "Tergnier"
        },
        {
            "codeTR3A": "SQ",
            "nom": "St Quentin"
        }
    ],
    "heureProbable": "02/08/2012 16:35",
    "heureTheorique": "02/08/2012 16:35",
    "numero": "847907",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 16:40",
    "heureTheorique": "02/08/2012 16:40",
    "numero": "847822",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "2",
    "voiePrecedente": null
},
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "LAI",
            "nom": "Laigneville"
        },
        {
            "codeTR3A": "LIA",
            "nom": "Liancourt Rantigny"
        },
        {
            "codeTR3A": "CDO",
            "nom": "Clermont de l'Oise"
        },
        {
            "codeTR3A": "AVY",
            "nom": "Avréchy"
        },
        {
            "codeTR3A": "SJS",
            "nom": "St Just en Chaussée"
        }
    ],
    "heureProbable": "02/08/2012 16:43",
    "heureTheorique": "02/08/2012 16:43",
    "numero": "848517",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "TOLI",
    "dessertes": [
        {
            "codeTR3A": "SLT",
            "nom": "St Leu d'Esserent"
        },
        {
            "codeTR3A": "PYO",
            "nom": "Précy sur Oise"
        },
        {
            "codeTR3A": "BRN",
            "nom": "Boran sur Oise"
        },
        {
            "codeTR3A": "BRK",
            "nom": "Bruyères sur Oise"
        },
        {
            "codeTR3A": "PEB",
            "nom": "Persan Beaumont"
        },
        {
            "codeTR3A": "CPO",
            "nom": "Champagne sur Oise"
        },
        {
            "codeTR3A": "IAP",
            "nom": "L'Isle Adam Parmain"
        },
        {
            "codeTR3A": "VMD",
            "nom": "Valmondois"
        },
        {
            "codeTR3A": "AUW",
            "nom": "Auvers sur Oise"
        },
        {
            "codeTR3A": "CPW",
            "nom": "Chaponval"
        },
        {
            "codeTR3A": "PPT",
            "nom": "Pont Petit"
        },
        {
            "codeTR3A": "EPL",
            "nom": "Epluches"
        },
        {
            "codeTR3A": "SOA",
            "nom": "St Ouen l'Aumone"
        },
        {
            "codeTR3A": "PSE",
            "nom": "Pontoise"
        }
    ],
    "heureProbable": "02/08/2012 16:54",
    "heureTheorique": "02/08/2012 16:54",
    "numero": "121042",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "TSOL",
    "dessertes": [],
    "heureProbable": "02/08/2012 17:07",
    "heureTheorique": "02/08/2012 17:07",
    "numero": "121031",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "AE",
    "voiePrecedente": null
}

]

什么问题?

4

1 回答 1

0

或许

        reader: {
            type: 'json',
            model: 'Train'
        }

??

于 2012-08-03T08:55:40.487 回答