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 :

Lancement d'un client REST avec l'invite de commande


Sujet :

Services Web Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    etudiante
    Inscrit en
    Mars 2018
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : etudiante
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2018
    Messages : 12
    Par défaut Lancement d'un client REST avec l'invite de commande
    Bonjour à tous,

    Comment lancer un client java REST avec le console?
    merci d'avance

  2. #2
    Membre Expert Avatar de yildiz-online
    Homme Profil pro
    Architecte de domaine
    Inscrit en
    Octobre 2011
    Messages
    1 447
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte de domaine

    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 447
    Par défaut
    un client rest c'est juste un appel HTTP, un curl fera donc l'affaire sous linux (et sous windows 10 à partir de la prochaine mise à jour)

    https://curl.haxx.se/docs/manpage.html

  3. #3
    Membre averti
    Femme Profil pro
    etudiante
    Inscrit en
    Mars 2018
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : etudiante
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2018
    Messages : 12
    Par défaut
    j'ai tapé ça: javac ClientJava.java
    il m'affiche ces erreurs:

    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
    65
    ClientJava.java:5: error: package javax.ws.rs does not exist
    import javax.ws.rs.Path;
                      ^
    ClientJava.java:6: error: package javax.ws.rs.client does not exist
    import javax.ws.rs.client.Client;
                             ^
    ClientJava.java:7: error: package javax.ws.rs.client does not exist
    import javax.ws.rs.client.ClientBuilder;
                             ^
    ClientJava.java:8: error: package javax.ws.rs.client does not exist
    import javax.ws.rs.client.WebTarget;
                             ^
    ClientJava.java:9: error: package javax.ws.rs.core does not exist
    import javax.ws.rs.core.MediaType;
                           ^
    ClientJava.java:10: error: package javax.ws.rs.core does not exist
    import javax.ws.rs.core.Response;
                           ^
    ClientJava.java:11: error: package javax.ws.rs.core does not exist
    import javax.ws.rs.core.UriBuilder;
                           ^
    ClientJava.java:13: error: package org.glassfish.jersey.client does not exist
    import org.glassfish.jersey.client.ClientConfig;
                                      ^
    ClientJava.java:16: error: cannot find symbol
            ClientConfig config = new ClientConfig();
            ^
      symbol:   class ClientConfig
      location: class ClientJava
    ClientJava.java:16: error: cannot find symbol
            ClientConfig config = new ClientConfig();
                                      ^
      symbol:   class ClientConfig
      location: class ClientJava
    ClientJava.java:18: error: cannot find symbol
            Client client = ClientBuilder.newClient(config);//Creating an Instance of a Client
            ^
      symbol:   class Client
      location: class ClientJava
    ClientJava.java:18: error: cannot find symbol
            Client client = ClientBuilder.newClient(config);//Creating an Instance of a Client
                            ^
      symbol:   variable ClientBuilder
      location: class ClientJava
    ClientJava.java:20: error: cannot find symbol
            WebTarget target = client.target(getBaseURI());// Creating a WebTarget using the URI of the targeted web resource:
            ^
      symbol:   class WebTarget
      location: class ClientJava
    ClientJava.java:22: error: cannot find symbol
            String response = target.path("aleatoire").path("oper1").request().accept(MediaType.TEXT_PLAIN).get(String.class);
                                                                                      ^
      symbol:   variable MediaType
      location: class ClientJava
    ClientJava.java:25: error: cannot find symbol
            String response2 = target.path("aleatoire").path("oper2").request().accept(MediaType.TEXT_PLAIN).get(String.class);
                                                                                       ^
      symbol:   variable MediaType
      location: class ClientJava
    ClientJava.java:31: error: cannot find symbol
                    return UriBuilder.fromUri("http://localhost:8081/WSalea").build();// nouvelle instance Ó partir d'une uri
                           ^
      symbol:   variable UriBuilder
      location: class ClientJava
    16 errors
    donc comment importer les bibliothèques jersey(sous windows)

  4. #4
    Membre Expert Avatar de yildiz-online
    Homme Profil pro
    Architecte de domaine
    Inscrit en
    Octobre 2011
    Messages
    1 447
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte de domaine

    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 447
    Par défaut
    ok ce n'est pas lancer mais compiler

    -cp pour ajouter un jar au classpath

  5. #5
    Membre averti
    Femme Profil pro
    etudiante
    Inscrit en
    Mars 2018
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : etudiante
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2018
    Messages : 12
    Par défaut
    j'ai importer tous les fichiers jar avec:
    javac -classpath javax.servlet-api-3.0.1.jar;javax.ws.rs-api-2.1.jar;jaxb-api-2.2.7.jar;jboss-interceptors-api_1.1_spec-1.0.0.Beta1.jar;jersey-client.jar;jersey-common.jar;jersey-container-servlet.jar;jersey-container-servlet-core.jar;jersey-hk2.jar;jersey-media-jaxb.jar;jersey-media-json-binding.jar;jersey-media-sse.jar;jersey-server.jar;jsr250-api-1.0.jar;org.osgi.core-4.2.0.jar;osgi-resource-locator-1.0.1.jar;persistence-api-1.0.jar;validation-api-1.1.0.Final.jar;yasson-1.0.jar;aopalliance-repackaged-2.5.0-b42.jar;cdi-api-1.1.jar;el-api-2.2.jar;hk2-api-2.5.0-b42.jar;hk2-locator-2.5.0-b42.jar;hk2-utils-2.5.0-b42.jar;javassist-3.22.0-CR2.jar;javax.annotation-api-1.2.jar;javax.inject-1.jar;javax.inject-2.5.0-b42.jar;javax.json.bind-api-1.0.jar;javax.json-1.1.jar;javax.json-api-1.1.jar ..\..\..\src\clientUC\ClientJava.java

    mais il affiche:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    warning: javax.ws.rs-api-2.1.jar(javax/ws/rs/Path.class): major version 52 is newer than 51, the highest major version supported by this compiler.
      It is recommended that the compiler be upgraded.
    warning: javax.ws.rs-api-2.1.jar(javax/ws/rs/client/Client.class): major version 52 is newer than 51, the highest major version supported by this compiler.
      It is recommended that the compiler be upgraded.
    warning: javax.ws.rs-api-2.1.jar(javax/ws/rs/client/ClientBuilder.class): major version 52 is newer than 51, the highest major version supported by this compiler.
      It is recommended that the compiler be upgraded.
    warning: javax.ws.rs-api-2.1.jar(javax/ws/rs/client/WebTarget.class): major version 52 is newer than 51, the highest major version supported by this compiler.
      It is recommended that the compiler be upg.

  6. #6
    Membre Expert Avatar de yildiz-online
    Homme Profil pro
    Architecte de domaine
    Inscrit en
    Octobre 2011
    Messages
    1 447
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte de domaine

    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 447
    Par défaut
    les librairies sont apparemment compilées en java 8 et toi tu utilises java 7

Discussions similaires

  1. Client REST avec CXF/Jax-RS, query hardcodée
    Par tchize_ dans le forum Services Web
    Réponses: 0
    Dernier message: 14/03/2017, 16h01
  2. Réponses: 3
    Dernier message: 11/05/2010, 19h51
  3. Réponses: 2
    Dernier message: 07/04/2008, 13h35
  4. [Access 2003] Communiquer avec l'invite de commande
    Par Faboul dans le forum VBA Access
    Réponses: 1
    Dernier message: 01/03/2008, 19h28
  5. se déplacer avec l'invite de commandes (windows xp)
    Par kriskikout dans le forum Langage
    Réponses: 9
    Dernier message: 05/05/2006, 15h59

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