IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Java Discussion :

Débutante web service Java avec NetBeans


Sujet :

Services Web Java

  1. #1
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut Débutante web service Java avec NetBeans
    Salut ,

    Je dois developper un WebService java J2EE,je pense qu'il est simple mais malheureusement, j'ai des problèmes pour réaliser mon application.

    en effet , j'ai deux grande problémes:

    1) quand j'ajoute une deuxième opération à mon web service , je ne peux pas mais le testé et l'erreur suivante m'affiche :
    deploy?path=C:\Users\d...\WebApplication2\build\web&name=WebApplication2&force=true failed on GlassFish Server 3
    C:\Users\d...\WebApplication2\nbproject\build-impl.xml:687: The module has not been deployed.
    BUILD FAILED (total time: 3 seconds)

    2) quand j'ai crée un client webservice , il ne m'affiche aucune erreur mais.. il ne fonctionne pas (reste run...)


    Pouvez vous m'aidez?
    Auriez vous un exemple simple pour me presenter un webService ??

    merci infiniment d'avance

  2. #2
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    est ce que tu peux nous faire montrer toute l'exception lors de déploiement de votre web service?
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

  3. #3
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    Merci bien pour votre réponse

    en déployant il m'affiche dans le console :

    init:
    deps-module-jar:
    deps-ear-jar:
    deps-jar:
    library-inclusion-in-archive:
    library-inclusion-in-manifest:
    compile:
    compile-jsps:
    In-place deployment at C:\Users\...\WebApplication2\build\web
    Initializing...
    deploy?path=C:\Users\...\WebApplication2\build\web&name=WebApplication2&force=true failed on GlassFish Server 3
    C:\Users\...\WebApplication2\nbproject\build-impl.xml:687: The module has not been deployed.
    BUILD FAILED (total time: 2 seconds)


    je pense que l'erreur provient du code de l'opération ajouté :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    @WebMethod(operationName = "SearchOperation")
        public JTable SearchOperation(@WebParam(name = "KeyWord")
        String KeyWord) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException{        String[] columnNames = {"Videos","Information"};
            JTable table = null;
            //---------Cconnexion à la base de données:----------------------
            String username = "root";
            String password = "0000";
            Statement stmt;
            ResultSet rs;
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            String url = "jdbc:mysql://localhost:3306/mabase";
            Connection conn = (Connection) DriverManager.getConnection(url, username, password);
            System.out.println("OK connexion réussie...");
            stmt = (Statement) conn.createStatement();
            rs = stmt.executeQuery("select * from videos where nomVideo='"+KeyWord+"'");
            String name=rs.getString("nomVideo");
           // ResultSetMetaData md = (ResultSetMetaData) rs.getMetaData();
            rs.last();
            int NbreResultats=rs.getRow();
            System.out.println("Le nombre des résultats vaut "+NbreResultats);// to del
            Object[][] data = new Object[NbreResultats][columnNames.length];
            rs.beforeFirst();
            String NEWLINE = System.getProperty("line.separator");
     
            while (rs.next()) { 
            String inf="";
            inf=inf+" Nom de la vidèo :"+rs.getString("nomVideo")+NEWLINE+
                    " Catégorie       :"+rs.getString("categorie")+NEWLINE+
                    " Durée           :"+rs.getString("duree")+NEWLINE;
            String Ligne1=" Nom de la vidèo :"+rs.getString("nomVideo");
            String Ligne2=" Catégorie       :"+rs.getString("categorie");
            String Ligne3=" Durée           :"+rs.getString("duree");
            String im=rs.getString("lien");
            System.out.println(im);// to del
            JLabel label =new JLabel("<html>"+Ligne1+"<br>"+Ligne2+"<br>"+Ligne3+"</html>");
            System.out.println(inf);
             data[0][0]=null;
            data[0][1]=label.getText();
     
            System.out.println(data[0][1].toString());
            rs.close();
            stmt.close();
            table = new JTable(data, columnNames);//enlever final
            table.setPreferredScrollableViewportSize(new Dimension(958, 581));
            table.setFillsViewportHeight(true);
            //table.setDefaultRenderer(null, this);
            ImageIcon iconv = new ImageIcon(im);
           // table.getColumnModel().getColumn(0).setCellRenderer((TableCellRenderer) new ImageRenderer());//importanteeeeee
            table.setRowHeight(300);
            JScrollPane scrollPane = new JScrollPane(table);//Create the scroll pane and add the table to it.
            table.add(scrollPane);//Add the scroll pane to this panel.
     
        }
     
    return table;
     
    }
    je compte bien sur votre aide , je suis assez débutante , je suis vraiment boquée ....

  4. #4
    Membre régulier
    Homme Profil pro
    Ingénieur développement de composants
    Inscrit en
    Mars 2011
    Messages
    94
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement de composants
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mars 2011
    Messages : 94
    Points : 87
    Points
    87
    Par défaut
    surement que l'erreur n'est pas dans le code malgré que votre code a beaucoup d'erreur.Vérifie bien le serveur Glassfish bien configuré ou non?
    D'autre part tu dois faire un try catch pour la connexion à la base c'est pas comme ça integré directement. De plus
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    String name=rs.getString("nomVideo");
    toute seule c'est faux ou doit etre dans un While pour parcourir le resultat.

  5. #5
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    Merci beaucoup

    votre réponse m'a bien servit ...
    j'ai ajouté un try catch autour de la connxion à la base
    il n'y a pas mainatenant des erreurs mais , le probléme que l'opération apparait sans aucun paramétre tant dis que c'est bien indiqué un String nommé KeyWord

    d'où provient le probléme SVP?

    Merci infiniment

  6. #6
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    fais nous voir ce que tu as ajouté ?
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

  7. #7
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    oui bien sur , maintenant aussi c bon l'opeartion apparaît avec son paramètre...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
        @WebMethod(operationName = "operation")
        public JTable operation(@WebParam(name = "key")
        String key)  {
            JTable table=null;
            try {
     
                //TODO write your implementation code here:
                String[] columnNames = {"Videos", "Information"};
                //---------Cconnexion à la base de données:----------------------
                String username = "root";
                String password = "0000";
                Statement stmt;
                ResultSet rs;
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                String url = "jdbc:mysql://localhost:3306/mabase";
                Connection conn = null;
                conn = (Connection) DriverManager.getConnection(url, username, password);
                System.out.println("OK connexion réussie...");
                stmt = (Statement) conn.createStatement();
                rs = stmt.executeQuery("select * from videos where nomVideo='" + key + "'");
                //  String name=rs.getString("nomVideo");
                // ResultSetMetaData md = (ResultSetMetaData) rs.getMetaData();
                rs.last();
                int NbreResultats = rs.getRow();
                System.out.println("Le nombre des résultats vaut " + NbreResultats); // to del
                Object[][] data = new Object[NbreResultats][columnNames.length];
                rs.beforeFirst();
                String NEWLINE = System.getProperty("line.separator");
                while (rs.next()) {
                    String inf = "";
                    inf = inf + " Nom de la vidèo :" + rs.getString("nomVideo") + NEWLINE + " Catégorie       :" + rs.getString("categorie") + NEWLINE + " Durée           :" + rs.getString("duree") + NEWLINE;
                    String Ligne1 = " Nom de la vidèo :" + rs.getString("nomVideo");
                    String Ligne2 = " Catégorie       :" + rs.getString("categorie");
                    String Ligne3 = " Durée           :" + rs.getString("duree");
                    String im = rs.getString("lien");
                    System.out.println(im); // to del
                    JLabel label = new JLabel("<html>" + Ligne1 + "<br>" + Ligne2 + "<br>" + Ligne3 + "</html>");
                    System.out.println(inf);
                    data[0][0] = null;
                    data[0][1] = label.getText();
                    System.out.println(data[0][1].toString());
                    rs.close();
                    stmt.close();
                    table = new JTable(data, columnNames); 
                    table.setPreferredScrollableViewportSize(new Dimension(958, 581));
                    table.setFillsViewportHeight(true);
                    //table.setDefaultRenderer(null, this);
                    ImageIcon iconv = new ImageIcon(im);
                    // table.getColumnModel().getColumn(0).setCellRenderer((TableCellRenderer) new ImageRenderer());//importanteeeeee
                    table.setRowHeight(300);
                    JScrollPane scrollPane = new JScrollPane(table); //Create the scroll pane and add the table to it.
                    table.add(scrollPane); //Add the scroll pane to this panel.
                }
     
            } catch (SQLException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            }return table;
        }
    mainant il fallait que je rectifie bien mes lignes...
    le type de retour pour que le web service doit être différents de jtable pour qu'il peut être appelée par n'importe quel client ...

  8. #8
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    j ai pas trouvé les variables convenable pour remplacer le JTable .

    j'essayer un String [][] , j'ai changé le code comme suit:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
     @WebMethod(operationName = "operation")
        public String[][] operation(@WebParam(name = "key")
        String key)  {
             String [][]data =null;
            try {
                //TODO write your implementation code here:
                String[] columnNames = {"Videos", "Information"};
                //---------Cconnexion à la base de données:----------------------
                String username = "root";
                String password = "0000";
                Statement stmt;
                ResultSet rs;
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                String url = "jdbc:mysql://localhost:3306/mabase";
                Connection conn = null;
                conn = (Connection) DriverManager.getConnection(url, username, password);
                System.out.println("OK connexion réussie...");
                stmt = (Statement) conn.createStatement();
                rs = stmt.executeQuery("select * from videos where nomVideo='" + key + "'");
     
                rs.last();
                int NbreResultats = rs.getRow();// n' a pas de sens non?
                System.out.println("Le nombre des résultats vaut " + NbreResultats); // to del
                data = new String[NbreResultats][columnNames.length];
                rs.beforeFirst();
                String NEWLINE = System.getProperty("line.separator");
                while (rs.next()) {
     
                    String im = rs.getString("lien");
                    System.out.println(im); // to del
     
                    String Info = ""+" Nom de la vidèo :" + rs.getString("nomVideo") + NEWLINE + " Catégorie       :" + rs.getString("categorie") + NEWLINE + " Durée           :" + rs.getString("duree") + NEWLINE;
                    System.out.println(Info);
                    int i=0;
                    data[i][0] = rs.getString("vignette");
                    data[i][1] = Info; 
                    i++;
                    }
                    rs.close();
                    stmt.close();
     
     
            } catch (SQLException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            }
             return data;
        }
    mais en le testant , il me retourne : java.util.List : "[]" !!!

    d'où provient le problème SVP?

    merci d'avance

  9. #9
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    est ce que tu peux nous montrer qu'est ce qu'il y a dans les log ?
    sinon remplace Logger.getLogger par des system.out.println();
    et fait nous voir qu'est ce que ça donne.
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

  10. #10
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    j'ai oublié d'ajouter la librairie de MySql

    mais le return devient mainant
    java.util.List : "[net.java.dev.jaxb.array.StringArray@6e94da76]" !!!

    Que dois-je faire SVP?

  11. #11
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    ceci net.java.dev.jaxb.array.StringArray@6e94da76 est un objet retourner de type String[][] qui est une matrice de données.
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

  12. #12
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    Oui exactement

    vous avez raison

    merci bien


    mais j'ai changé cette partie de code je veux que cette méthode me retourne un jtable

    pouvez vous m'aider?
    je suis bloquée?

  13. #13
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    je pense que ta methode doit retourner un String [][] comme tu as mis et dans ta classe que tu vas faire ajouter ton JTable tu dois parcourir Le String [][] et le Setter dans dans JTable
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

  14. #14
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2011
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Mars 2011
    Messages : 24
    Points : 15
    Points
    15
    Par défaut
    oui c'est logique

    mais le problème est que je ne maîtrise pas le développement des clients web service , et avec un type de retour String [][] , la tâche serai plus difficile
    es-c'est vrai?
    avez vous une idée?

  15. #15
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Points : 955
    Points
    955
    Par défaut
    dans tous les cas tu as besoin de cette transformation :
    mais comme tu veux je te donne un petit bout de code pour faire ce que tu veux:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    //columnNames c'est un tableau que tu dois y définir les noms de tes colonnes 
    String[] columnNames = {"First Name",
                    "Last Name",
                    "Sport",
                    "# of Years",
                    "Vegetarian"};
     
    		//data c'est ton String[][]
    		JTable table = new JTable(data, columnNames);
    Ce qu'on appelons le hasard n'est que notre incapacité à comprendre un degré d'ordre supérieur.

Discussions similaires

  1. problème avec web services java netbeans
    Par amanimannou dans le forum Services Web
    Réponses: 1
    Dernier message: 01/04/2011, 16h56
  2. Réponses: 10
    Dernier message: 26/08/2010, 11h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo