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

avec Java Discussion :

Appeler Web Service dans application Java


Sujet :

avec Java

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2015
    Messages : 3
    Points : 1
    Points
    1
    Par défaut Appeler Web Service dans application Java
    Bonjour,

    J'ai créé un service web "Somme" sous Eclipse et une application web simple "AppelSomme".

    Je cherche comment faire pour appeler le service web "Somme" dans l'application Java "AppelSomme".

    Quelqu'un saurait-il m'indiquer comment faire ?

    Merci d'avance pour votre aide.

  2. #2
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2015
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    !!!!!!!!!!!!!!!!!

  3. #3
    Membre confirmé
    Avatar de provirus
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2009
    Messages
    248
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2009
    Messages : 248
    Points : 580
    Points
    580
    Par défaut
    Bonjour,

    J'ai créé un service web "Somme" sous Eclipse et une application web simple "AppelSomme".
    Il y a plusieurs sortes de services web: soap, rest, RMI, ...
    Il y a plusieurs technologies Java pour en faire: JSP, Spring MVC, Apache CXF, ...

    Comme tu dis que tu as fait une application web simple, je vais supposer que c'est juste un url comme : http://localhost:8080/somme/appelSomme.jsp?a=10&b=20 et que ce url afficherait 30.


    Partant de là, tu peux tout simplement utiliser un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    new URL("http://localhost:8080/somme/appelSomme.jsp?a=10&b=20");
    .
    Si tu veux plus de flexibilités, tu peux regarder du côté d'Apache HTTP Client: https://hc.apache.org/
    Ou ce que j'aime bien avec Spring:


    Si tu as d'autres précisions, nous pourrons te suggérer d'autres choses.

  4. #4
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2015
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2015
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Bonjour,

    Merci pour la réponse

    J'ai crée un service web "Somme " avec eclipse, Tomact 6, axis 2

    Nom : Capture1.PNG
Affichages : 167
Taille : 30,0 Ko

    public class Somme {

    public int somme(int x, int y){
    return x+y;
    }


    }
    et une Application normal java "AppelSomme"

    Nom : Capture.PNG
Affichages : 161
Taille : 17,5 Ko
    import javax.swing.*;
    import java.awt.*;
    public class AppelSomme extends javax.swing.JFrame{
    public AppelSomme() {
    initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jTextField2 = new javax.swing.JTextField();
    jTextField3 = new javax.swing.JTextField();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel1.setText("X: ");

    jLabel2.setText("Y: ");

    jLabel3.setText("Z:");

    jButton1.setText("Go");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(55, 55, 55)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel3)
    .addGap(18, 18, 18)
    .addComponent(jTextField3))
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel1)
    .addGap(18, 18, 18)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel2)
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jButton1)
    .addComponent(jTextField2))))
    .addContainerGap(235, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(35, 35, 35)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel1)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    .addComponent(jButton1)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel3)
    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap())
    );

    pack();
    }// </editor-fold>

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new AppelSomme().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    // End of variables declaration

    }

    je veux appeler le service web "somme" dans l'application "AppelSomme"

  5. #5
    Membre confirmé
    Avatar de provirus
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2009
    Messages
    248
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2009
    Messages : 248
    Points : 580
    Points
    580
    Par défaut
    Ok.

    Axis2 te donne un WSDL (comme ton image l'indique).
    À partir de ce WSDL, en utilisant les outils d'Axis2, tu peux générer le code client. Les étapes à franchir sont indiquées ici: https://axis.apache.org/axis2/java/c...#createclients

Discussions similaires

  1. appel web service java en php
    Par legide dans le forum Services Web
    Réponses: 0
    Dernier message: 09/07/2009, 19h57
  2. Appeler un service web depuis mon application Java
    Par Lord Yu dans le forum Services Web
    Réponses: 12
    Dernier message: 26/06/2009, 15h40
  3. Intégrer un web service dans une application java
    Par madjidri dans le forum Services Web
    Réponses: 2
    Dernier message: 08/06/2008, 14h53
  4. Appel d'un Web Services dans php
    Par ggjedi dans le forum Services Web
    Réponses: 1
    Dernier message: 05/02/2008, 10h32
  5. Réponses: 7
    Dernier message: 17/10/2007, 17h06

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