ben-barbier / YouGo-AngularJS

1 stars 1 forks source link

Use Yougo-back services of Heroku #4

Open ben-barbier opened 11 years ago

ben-barbier commented 11 years ago

URL : http://stormy-everglades-6441.herokuapp.com/api/users/

ben-barbier commented 11 years ago

Hello, j'ai tenté avec cette méthode (qui fonctionne pour un autre de mes projets) : services.js :

services.factory('Users', function($resource){
  return $resource('http://stormy-everglades-6441.herokuapp.com/api/users/');
});

controllers.js :

$scope.users = Users.query();

Mon navigateur envoie dans un 1er temps une requête OPTION avant de se faire jeter par le serveur. Je pense tout simplement que l'application YouGo-Back, ne sait pas gérer les appels CORS (la spécification liée à le requête OPTION est assez récente).

Je te propose de mettre à jour l'appli YouGo-Back pour coller au nouveau standard quand tu auras quelques minutes devant toi.

Pour info, j'ai réussi à le faire sur une autre appli en suivant ce tuto : http://blog.kdecherf.com/2011/06/02/java-jersey-une-api-rest-cross-domain-sans-jsonp/

Bonne nuit.

++

fdescamps commented 11 years ago

Oki Merci,

J'ai commencé à travaillé sur le sujet ;)

J'avance dès que possible, mes filles viennent de se réveiller ...

ben-barbier commented 11 years ago

Alors mec, ca donne quoi ?

Si tu veux je peux faire la modif mais il me faudrait un accés à ton repo Heroku ;-)

Mon login Heroku est mon gmail (je ne sais même pas si il est possible de partager l'accés)...

@+ mec !

fdescamps commented 11 years ago

Salut mec,

Désolé en ce moment le projet chez mon client c'est chaud chaud et avec la famille et le marathon je lutte pour trouver du temps !

J'ai fais la modification mais il persiste un problème ! J'ai tout mis sur mon repo github : https://github.com/fdescamps/YouGo-back Classe de filtre : https://github.com/fdescamps/YouGo-back/blob/master/yougo-web/src/main/java/com/ineatconseil/yougo/security/CORSFilter.java

Si tu peux jeter un oeil et m'aider, je suis preneur !

@+ désolé de faire traîner !!!

ben-barbier commented 11 years ago

OK merci pour les infos... Je ne vais pas avoir trop de temps non plus dans les jours à venir mais au cas ou, je sais ou aller voir maintenant ;-) Merci !

++

fdescamps commented 11 years ago

Bon ça marche :d faut que je rende ça propre mais ça marche...

Forcément mes filles sont réveillées ....

fdescamps commented 11 years ago

J'ai bien ça dans la réponse http : [{"active":true,"admin":true,"email":"kristina.chung@company.com","fullName":"Kristina CHUNG","id":1,"typeId":1},{"active":true,"admin":false,"email":"paige.chen@company.com","fullName":"Paige CHEN","id":2,"typeId":1},{"active":true,"admin":false,"email":"sherri.melton@company.com","fullName":"Sherri MELTON","id":3,"typeId":1},{"active":true,"admin":false,"email":"gretchen.hill@company.com","fullName":"Gretchen HILL","id":4,"typeId":1},{"active":true,"admin":false,"email":"karen.puckett@company.com","fullName":"Karen PUCKETT","id":5,"typeId":1},{"active":true,"admin":false,"email":"patrick.song@company.com","fullName":"Patrick SONG","id":6,"typeId":1},{"active":true,"admin":false,"email":"elsie.hamilton@company.com","fullName":"Elsie HAMILTON","id":7,"typeId":1},{"active":true,"admin":false,"email":"hazel.bender@company.com","fullName":"Hazel BENDER","id":8,"typeId":1},{"active":true,"admin":false,"email":"malcolm.wagner@company.com","fullName":"Malcolm WAGNER","id":9,"typeId":1},{"active":true,"admin":false,"email":"dolores.mclaughlin@company.com","fullName":"Dolores MCLAUGHLIN","id":10,"typeId":1},{"active":true,"admin":false,"email":"francis.mcnamara@company.com","fullName":"Francis MCNAMARA","id":11,"typeId":1},{"active":true,"admin":false,"email":"sandy.raynor@company.com","fullName":"Sandy RAYNOR","id":12,"typeId":1},{"active":true,"admin":false,"email":"marion.moon@company.com","fullName":"Marion MOON","id":13,"typeId":1},{"active":true,"admin":false,"email":"beth.woodard@company.com","fullName":"Beth WOODARD","id":14,"typeId":1},{"active":true,"admin":false,"email":"julia.desai@company.com","fullName":"Julia DESAI","id":15,"typeId":1},{"active":true,"admin":false,"email":"jerome.wallace@company.com","fullName":"Jerome WALLACE","id":16,"typeId":1},{"active":true,"admin":false,"email":"neal.lawrence@company.com","fullName":"Neal LAWRENCE","id":17,"typeId":1},{"active":true,"admin":false,"email":"jean.griffin@company.com","fullName":"Jean GRIFFIN","id":18,"typeId":1},{"active":true,"admin":false,"email":"kristine.dougherty@company.com","fullName":"Kristine DOUGHERTY","id":19,"typeId":1},{"active":true,"admin":false,"email":"crystal.powers@company.com","fullName":"Crystal POWERS","id":20,"typeId":1},{"active":true,"admin":false,"email":"alex.may@company.com","fullName":"Alex MAY","id":21,"typeId":1},{"active":true,"admin":false,"email":"eric.steele@company.com","fullName":"Eric STEELE","id":22,"typeId":1},{"active":true,"admin":false,"email":"wesley.teague@company.com","fullName":"Wesley TEAGUE","id":23,"typeId":1},{"active":true,"admin":false,"email":"franklin.vick@company.com","fullName":"Franklin VICK","id":24,"typeId":1},{"active":true,"admin":false,"email":"claire.gallagher@company.com","fullName":"Claire GALLAGHER","id":25,"typeId":1},{"active":true,"admin":false,"email":"marian.solomon@company.com","fullName":"Marian SOLOMON","id":26,"typeId":1},{"active":true,"admin":false,"email":"marcia.walsh@company.com","fullName":"Marcia WALSH","id":27,"typeId":1},{"active":true,"admin":false,"email":"dwight.monroe@company.com","fullName":"Dwight MONROE","id":28,"typeId":1},{"active":true,"admin":false,"email":"wayne.connolly@company.com","fullName":"Wayne CONNOLLY","id":29,"typeId":1},{"active":true,"admin":false,"email":"stephanie.hawkins@company.com","fullName":"Stephanie HAWKINS","id":30,"typeId":1},{"active":true,"admin":false,"email":"neal.middleton@company.com","fullName":"Neal MIDDLETON","id":31,"typeId":1},{"active":true,"admin":false,"email":"gretchen.goldstein@company.com","fullName":"Gretchen GOLDSTEIN","id":32,"typeId":1},{"active":true,"admin":false,"email":"tim.watts@company.com","fullName":"Tim WATTS","id":33,"typeId":1},{"active":true,"admin":false,"email":"jerome.johnston@company.com","fullName":"Jerome JOHNSTON","id":34,"typeId":1},{"active":true,"admin":false,"email":"shelley.weeks@company.com","fullName":"Shelley WEEKS","id":35,"typeId":1},{"active":true,"admin":false,"email":"priscilla.wilkerson@company.com","fullName":"Priscilla WILKERSON","id":36,"typeId":1},{"active":true,"admin":false,"email":"elsie.barton@company.com","fullName":"Elsie BARTON","id":37,"typeId":1},{"active":true,"admin":false,"email":"beth.walton@company.com","fullName":"Beth WALTON","id":38,"typeId":1},{"active":true,"admin":false,"email":"erica.hall@company.com","fullName":"Erica HALL","id":39,"typeId":1},{"active":true,"admin":false,"email":"douglas.ross@company.com","fullName":"Douglas ROSS","id":40,"typeId":1},{"active":true,"admin":false,"email":"donald.chung@company.com","fullName":"Donald CHUNG","id":41,"typeId":1},{"active":true,"admin":false,"email":"katherine.bender@company.com","fullName":"Katherine BENDER","id":42,"typeId":1},{"active":true,"admin":false,"email":"paul.woods@company.com","fullName":"Paul WOODS","id":43,"typeId":1},{"active":true,"admin":false,"email":"patricia.mangum@company.com","fullName":"Patricia MANGUM","id":44,"typeId":1},{"active":true,"admin":false,"email":"lois.joseph@company.com","fullName":"Lois JOSEPH","id":45,"typeId":1},{"active":true,"admin":false,"email":"louis.rosenthal@company.com","fullName":"Louis ROSENTHAL","id":46,"typeId":1},{"active":true,"admin":false,"email":"christina.bowden@company.com","fullName":"Christina BOWDEN","id":47,"typeId":1},{"active":true,"admin":false,"email":"darlene.barton@company.com","fullName":"Darlene BARTON","id":48,"typeId":1},{"active":true,"admin":false,"email":"harvey.underwood@company.com","fullName":"Harvey UNDERWOOD","id":49,"typeId":1},{"active":true,"admin":false,"email":"william.jones@company.com","fullName":"William JONES","id":50,"typeId":1},{"active":true,"admin":false,"email":"frederick.baker@company.com","fullName":"Frederick BAKER","id":51,"typeId":1},{"active":true,"admin":false,"email":"shirley.merritt@company.com","fullName":"Shirley MERRITT","id":52,"typeId":1},{"active":true,"admin":false,"email":"jason.cross@company.com","fullName":"Jason CROSS","id":53,"typeId":1},{"active":true,"admin":false,"email":"judith.cooper@company.com","fullName":"Judith COOPER","id":54,"typeId":1},{"active":true,"admin":false,"email":"gretchen.holmes@company.com","fullName":"Gretchen HOLMES","id":55,"typeId":1},{"active":true,"admin":false,"email":"don.sharpe@company.com","fullName":"Don SHARPE","id":56,"typeId":1},{"active":true,"admin":false,"email":"glenda.morgan@company.com","fullName":"Glenda MORGAN","id":57,"typeId":1},{"active":true,"admin":false,"email":"scott.hoyle@company.com","fullName":"Scott HOYLE","id":58,"typeId":1},{"active":true,"admin":false,"email":"pat.allen@company.com","fullName":"Pat ALLEN","id":59,"typeId":1},{"active":true,"admin":false,"email":"michelle.rich@company.com","fullName":"Michelle RICH","id":60,"typeId":1},{"active":true,"admin":false,"email":"jessica.rich@company.com","fullName":"Jessica RICH","id":61,"typeId":1},{"active":true,"admin":false,"email":"evan.grant@company.com","fullName":"Evan GRANT","id":62,"typeId":1},{"active":true,"admin":false,"email":"melinda.proctor@company.com","fullName":"Melinda PROCTOR","id":63,"typeId":1},{"active":false,"admin":false,"email":"calvin.diaz@company.com","fullName":"Calvin DIAZ","id":64,"typeId":1},{"active":false,"admin":false,"email":"eugene.graham@company.com","fullName":"Eugene GRAHAM","id":65,"typeId":1},{"active":false,"admin":false,"email":"vickie.watkins@company.com","fullName":"Vickie WATKINS","id":66,"typeId":1},{"active":false,"admin":false,"email":"luis.hinton@company.com","fullName":"Luis HINTON","id":67,"typeId":1},{"active":false,"admin":false,"email":"allan.marsh@company.com","fullName":"Allan MARSH","id":68,"typeId":1},{"active":true,"admin":false,"email":"melanie.hewitt@company.com","fullName":"Melanie HEWITT","id":69,"typeId":2},{"active":true,"admin":false,"email":"marianne.branch@company.com","fullName":"Marianne BRANCH","id":70,"typeId":2},{"active":true,"admin":false,"email":"natalie.walton@company.com","fullName":"Natalie WALTON","id":71,"typeId":2},{"active":true,"admin":false,"email":"caroline.o'brien@company.com","fullName":"Caroline O'BRIEN","id":72,"typeId":2},{"active":true,"admin":true,"email":"arlene.case@company.com","fullName":"Arlene CASE","id":73,"typeId":3},{"active":true,"admin":true,"email":"kyle.watts@company.com","fullName":"Kyle WATTS","id":74,"typeId":3},{"active":true,"admin":true,"email":"calvin.christensen@company.com","fullName":"Calvin CHRISTENSEN","id":75,"typeId":3},{"active":true,"admin":false,"email":"gary.parks@company.com","fullName":"Gary PARKS","id":76,"typeId":3},{"active":true,"admin":false,"email":"samantha.hardin@company.com","fullName":"Samantha HARDIN","id":77,"typeId":4},{"active":true,"admin":false,"email":"sara.lucas@company.com","fullName":"Sara LUCAS","id":78,"typeId":4},{"active":true,"admin":false,"email":"stacy.eason@company.com","fullName":"Stacy EASON","id":79,"typeId":4},{"active":true,"admin":false,"email":"gladys.davidson@company.com","fullName":"Gladys DAVIDSON","id":80,"typeId":4}]

mais le truc c'est qu'il faut qu'il s'affiche.... on dirait que c'est tombé en erreur... je verrais ça des que possible... en attendant je push le back !

fdescamps commented 11 years ago

Et des que j'ai une version client+ serveur stable, je push sur le heroku ;)

fdescamps commented 11 years ago

j'ai aussi push mon client ici si tu veux aller voir dans services ;)

fdescamps commented 11 years ago

Ouep c'est bien ce que je pensais ça passe dans error: return $http.jsonp( url ). success(function(data, status, headers, config) { console.log("status: "+status+", headers: "+headers+", config: "+config+", data: "+data); return data; }). error(function(data, status, headers, config){ console.log("status: "+status+", headers: "+headers+", config: "+config+", data: "+data); alert("ERROR: Could not get data."); return data; });

et ça donne :

Réponse entête Content-Type application/json Date Sun, 21 Apr 2013 13:52:51 GMT Server Apache-Coyote/1.1 Transfer-Encoding chunked Requêtevoir le code source Accept / Accept-Encoding gzip, deflate Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Authorization Basic a3Jpc3RpbmEuY2h1bmdAY29tcGFueS5jb206cGFzc3dvcmQ= Connection keep-alive Cookie JSESSIONID=E549D39178DC8AA152FED2B088978F9E Host localhost:8080 Referer http://localhost:8000/app/index.html User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:20.0) Gecko/20100101 Firefox/20.0

et en corps de répons : [{"active":true,"admin":true,"email":"kristina.chung@company.com","fullName":"Kristina CHUNG","id":1....

fdescamps commented 11 years ago

Voilà, dès que je peux je continue ! Tout le code est : https://github.com/fdescamps/YouGo-back et https://github.com/fdescamps/YouGo-AngularJS

ben-barbier commented 11 years ago

Re,

Je pense que le problème est lié à la méthode utilisée... On a 2 choix : soit le JSONP soit la preflight request (requête OPTIONS). Ici, si on utilisent la preflight request (la méthode la plus classe ^^). Il faut donc faire un $http. get() et pas un $http. jsonp().

Je vais jeter un oeil ce soir ;-)

++

fdescamps commented 11 years ago

Hi, je n'ai rien trouvé et toi as tu pu regarder ?