Exemple très simple de service web REST

Fermé
keviin55 Messages postés 6 Date d'inscription mardi 12 avril 2011 Statut Membre Dernière intervention 6 novembre 2015 - 12 avril 2011 à 20:54
mpmp93 Messages postés 6651 Date d'inscription mercredi 13 avril 2011 Statut Membre Dernière intervention 28 septembre 2015 - 4 mai 2011 à 13:33
Salut tout le monde ,
je suis très débutant et cherche à faire un exemple très d'un service web avec l'architecture REST .
J'ai installer glassfish , jersey et netbeans .

J'ai essayer un exemple Hello world que j'ai trouver sur netbeans


package helloworld;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import javax.ws.rs.Path;
import javax.ws.rs.GET;

import javax.ws.rs.Produces;




@Stateless
@Path("/helloWorld")
public class HelloWorldResource {

    @EJB
    private NameStorageBean nameStorage;
    
    @GET
    @Produces("text/html")
    public String getXml() {
        return "<html><body><h1>Hello  "+nameStorage.getName()+"!</h1></body></html>";
    }

}



La je voudrais savoir comment transformer le résultat en JSON ?
j'ai chercher beaucoup sur google mais je trouve pas quelque chose de claire.

merci d'avance


A voir également:

1 réponse

mpmp93 Messages postés 6651 Date d'inscription mercredi 13 avril 2011 Statut Membre Dernière intervention 28 septembre 2015 1 331
4 mai 2011 à 13:33
Bonjour,

Une solution éprouvée ici:
http://framework.zend.com/manual/en/zend.rest.html

A+
0