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 :

Petit exemple web service avec CXF


Sujet :

Services Web Java

  1. #21
    oca
    oca est déconnecté
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    354
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2004
    Messages : 354
    Points : 421
    Points
    421
    Par défaut
    C'est le client ou le serveur qui affiche cette erreur ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    java.lang.NoClassDefFoundError: com/sun/xml/fastinfoset/stax/StAXDocumentParser
    cela ressemble à un problème de classpath... il manque peut-être une lib...
    ou un problème de version ?

    En tout cas je n'ai pas cette erreur avec la même version de java que toi (1.6.05)
    A+

  2. #22
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    16
    Détails du profil
    Informations personnelles :
    Âge : 35

    Informations forums :
    Inscription : Mai 2008
    Messages : 16
    Points : 4
    Points
    4
    Par défaut
    C'est le client, je fais un Run As Appli Java sur le Client.java en fait.

    Je vais essayer de voir si il me manque une librairie...

  3. #23
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    16
    Détails du profil
    Informations personnelles :
    Âge : 35

    Informations forums :
    Inscription : Mai 2008
    Messages : 16
    Points : 4
    Points
    4
    Par défaut
    Bon, j'ai toujours pas trouvé d'où venait l'erreur, je suis donc passer à autre chose (ce qui me donne d'autres erreurs )

    D'après l'exemple présent sur ce site (sur 4 pages) :
    http://wheelersoftware.com/articles/...-services.html

    Mon projet se nomme "UltimeProjetCxf" et possède...

    La classe Message
    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
    package contactus;
     
    import org.apache.cxf.aegis.type.java5.IgnoreProperty;
     
    public final class Message {
        private String firstName;
        private String lastName;
        private String email;
        private String text;
     
        public Message() {
        }
     
        public Message(String firstName, String lastName, String email, String text) {
            this.firstName = firstName;
            this.lastName = lastName;
            this.email = email;
            this.text = text;
        }
     
        public String getFirstName() {
            return firstName;
        }
     
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }
     
        public String getLastName() {
            return lastName;
        }
     
        public void setLastName(String lastName) {
            this.lastName = lastName;
        }
     
        @IgnoreProperty
        public String getLastNameFirstName() {
            return lastName + ", " + firstName;
        }
     
        public String getEmail() {
            return email;
        }
     
        public void setEmail(String email) {
            this.email = email;
        }
     
        public String getText() {
            return text;
        }
     
        public void setText(String text) {
            this.text = text;
        }
    }
    L'interface ContactUsService
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    package contactus;
     
    import java.util.List;
     
    import javax.jws.WebParam;
    import javax.jws.WebService;
     
    @WebService
    public interface ContactUsService {
     
        List<Message> getMessages();
     
        void postMessage(@WebParam(name = "message") Message message);
    }
    La classe ContactUsServiceImpl
    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
    package contactus;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.jws.WebService;
     
    @WebService(endpointInterface = "contactus.ContactUsService")
    public final class ContactUsServiceImpl implements ContactUsService {
     
        @Override
        public List<Message> getMessages() {
            List<Message> messages = new ArrayList<Message>();
            messages.add(new Message(
                    "Willie", "Wheeler", "willie.wheeler@xyz.com", "Great job"));
            messages.add(new Message(
                    "Dardy", "Chen", "dardy.chen@xyz.com", "I want my money back"));
            return messages;
        }
     
        @Override
        public void postMessage(Message message) {
            System.out.println(message);
        }
    }
    appContext.xml présent dans WEB-INF\
    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
    <?xml version="1.0" encoding="UTF-8"?>
     
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:cxf="http://cxf.apache.org/core"
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://cxf.apache.org/core
            http://cxf.apache.org/schemas/core.xsd
            http://cxf.apache.org/jaxws
            http://cxf.apache.org/schemas/jaxws.xsd"
        default-autowire="byName">
     
        <!-- Load CXF modules from cxf.jar -->
        <import resource="classpath:META-INF/cxf/cxf.xml" />
        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
     
        <!-- Enable message logging using the CXF logging feature -->
        <cxf:bus>
            <cxf:features>
                <cxf:logging/>
            </cxf:features>
        </cxf:bus>
     
        <!-- The service bean -->
        <bean id="contactUsServiceImpl" class="contactus.ContactUsServiceImpl"/>
     
        <!-- Aegis data binding -->
        <bean id="aegisBean"
            class="org.apache.cxf.aegis.databinding.AegisDatabinding"
            scope="prototype"/> 
        <bean id="jaxws-and-aegis-service-factory"
            class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
            scope="prototype">
            <property name="dataBinding" ref="aegisBean"/>
            <property name="serviceConfigurations">
                <list>
                  <bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
                  <bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
                  <bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/> 
                </list>
            </property>
        </bean>
     
        <!-- Service endpoint -->
        <!-- See http://incubator.apache.org/cxf/faq.html regarding CXF + Spring AOP -->
        <jaxws:endpoint id="contactUsService"
                implementorClass="contactus.ContactUsServiceImpl"
                implementor="#contactUsServiceImpl"
                address="/contactus">
            <jaxws:serviceFactory>
                <ref bean="jaxws-and-aegis-service-factory"/>
            </jaxws:serviceFactory>
        </jaxws:endpoint>
    </beans>
    et le Web.xml aussi présent dans WEB-INF\
    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
    <?xml version="1.0" encoding="UTF-8"?>
     
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="services" version="2.5">
     
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/appContext.xml</param-value>
        </context-param>
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>
        <servlet>
            <servlet-name>CXFServlet</servlet-name>
            <servlet-class>
                org.apache.cxf.transport.servlet.CXFServlet
            </servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>CXFServlet</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    </web-app>

    Ce qui me donne la stacktrace suivante au démarrage de Tomcat 6.0 :
    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
    22 mai 2008 12:15:57 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:WebCxf' did not find a matching property.
    22 mai 2008 12:15:57 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyWebProject' did not find a matching property.
    22 mai 2008 12:15:57 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ProjetWebCxf' did not find a matching property.
    22 mai 2008 12:15:57 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:UltimeProjetCxf' did not find a matching property.
    22 mai 2008 12:15:57 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_05\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.6.0_05\bin\..\jre\bin\client;C:\Program Files\Java\jdk1.6.0_05\bin\..\jre\bin;D:\logiciels\oracle\app\oracle\product\10.2.0\server\bin;C:\Program Files\Java\jdk1.6.0_05\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\QuickTime\QTSystem;d:\PACK_UNILOG\a019341\profil\Mes Documents\Software & Doc\apache-cxf-2.1\apache-cxf-2.1\bin;d:\PACK_UNILOG\a019341\profil\Mes Documents\Software & Doc\maven209\bin;C:\Documents and Settings\maaloufn.GROUPINFRA\Mes documents\JavaDev\ProjetAnt\;d:\PACK_UNILOG\a019341\profil\Mes Documents\Software & Doc\apache-ant-1.7.0\bin
    22 mai 2008 12:15:57 org.apache.coyote.http11.Http11Protocol init
    INFO: Initialisation de Coyote HTTP/1.1 sur http-8082
    22 mai 2008 12:15:57 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 579 ms
    22 mai 2008 12:15:57 org.apache.catalina.core.StandardService start
    INFO: Démarrage du service Catalina
    22 mai 2008 12:15:57 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
    22 mai 2008 12:15:58 org.apache.catalina.util.ExtensionValidator validateManifestResources
    INFO: ExtensionValidator[/UltimeProjetCxf][commons-attributes-compiler.jar]: L'extension requise "ant" est introuvable.
    22 mai 2008 12:15:58 org.apache.catalina.util.ExtensionValidator validateManifestResources
    INFO: ExtensionValidator[/UltimeProjetCxf][commons-attributes-compiler.jar]: L'extension requise "qdox" est introuvable.
    22 mai 2008 12:15:58 org.apache.catalina.util.ExtensionValidator validateManifestResources
    INFO: ExtensionValidator[/UltimeProjetCxf][commons-attributes-compiler.jar]: L'extension requise "commons-attributes-api" est introuvable.
    22 mai 2008 12:15:58 org.apache.catalina.util.ExtensionValidator validateManifestResources
    INFO: ExtensionValidator[/UltimeProjetCxf][commons-attributes-compiler.jar]: L'extension requise "javadoc" est introuvable.
    22 mai 2008 12:15:58 org.apache.catalina.util.ExtensionValidator validateManifestResources
    INFO: ExtensionValidator[/UltimeProjetCxf]: Impossible de trouver 4 extension(s) requise(s).
    22 mai 2008 12:15:58 org.apache.catalina.core.StandardContext start
    GRAVE: Error getConfigured
    22 mai 2008 12:15:58 org.apache.catalina.core.StandardContext start
    GRAVE: Erreur de démarrage du contexte [/UltimeProjetCxf] suite aux erreurs précédentes
    22 mai 2008 12:15:58 org.apache.catalina.core.StandardContext stop
    INFO: Le conteneur org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/UltimeProjetCxf] n'a pas été démarré
    22 mai 2008 12:15:58 org.apache.coyote.http11.Http11Protocol start
    INFO: Démarrage de Coyote HTTP/1.1 sur http-8082
    22 mai 2008 12:15:58 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    22 mai 2008 12:15:58 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/47  config=null
    22 mai 2008 12:15:58 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 561 ms
    Le screenshot de mon projet



    Merci de votre aide...

  4. #24
    oca
    oca est déconnecté
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    354
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2004
    Messages : 354
    Points : 421
    Points
    421
    Par défaut
    Sur ton problème précédant, la class com.sun.xml.fastinfoset.stax.StAXDocumentParser

    vient du jdk 1.6.05 lui-même. je pense que tu as un problème dans la config de ton projet
    A+

  5. #25
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    16
    Détails du profil
    Informations personnelles :
    Âge : 35

    Informations forums :
    Inscription : Mai 2008
    Messages : 16
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par oca Voir le message
    Sur ton problème précédant, la class com.sun.xml.fastinfoset.stax.StAXDocumentParser

    vient du jdk 1.6.05 lui-même. je pense que tu as un problème dans la config de ton projet
    A+
    Yop c'est résolu pour ce problème, c'était une JAR de CXF qui manquait.

    Question : quelle url dois-je placer dans factory.setAddress() ?

    Jusqu'ici je plaçais celle de mon context root, est-ce correct ?

  6. #26
    oca
    oca est déconnecté
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    354
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2004
    Messages : 354
    Points : 421
    Points
    421
    Par défaut
    tu passes l'adresse du endpoint du service. tu peux le voir dans ta wsdl


    java :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    factory.setAddress("http://localhost:9083/test");

    wsdl :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ...
    ...
     <wsdl:service name="IService">
     <wsdl:port binding="tns:IServiceSoapBinding" name="IServicePort">
      <soap:address location="http://localhost:9083/test" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
    [edit]
    si tu passes par un projet web por deployertes services , cela ressemblera plus à :

    factory.setAddress("http://localhost:8080/webCxf/services/hello_world");


    http://localhost:8080/webCxf/services/hello_world?wsdl
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <wsdl:service name="HelloWorld"> <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldPort">
      <soap:address location="http://localhost:8080/webCxf/services/hello_world" /> 
      </wsdl:port>
      </wsdl:service>
    [/edit]

  7. #27
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    16
    Détails du profil
    Informations personnelles :
    Âge : 35

    Informations forums :
    Inscription : Mai 2008
    Messages : 16
    Points : 4
    Points
    4
    Par défaut
    Ca marche !

    J'ai résussi à faire fonctionner mon client, j'avais des erreurs à cause d'un mauvais URL dans factory.setAddress() justemment.

    Merci pour ton aide !!

  8. #28
    oca
    oca est déconnecté
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    354
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2004
    Messages : 354
    Points : 421
    Points
    421
    Par défaut
    Cooolllll !!!!

  9. #29
    Candidat au Club
    Inscrit en
    Mai 2008
    Messages
    16
    Détails du profil
    Informations personnelles :
    Âge : 35

    Informations forums :
    Inscription : Mai 2008
    Messages : 16
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par oca Voir le message
    Cooolllll !!!!
    Un grand merci à toi t'as été super !


+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Problème génération client web service avec CXF(wsdl2java)
    Par riadhhwajdii dans le forum Services Web
    Réponses: 0
    Dernier message: 19/06/2014, 12h04
  2. Différences entre les Web Services avec Apache CXF et Axis2
    Par olivier75000 dans le forum Services Web
    Réponses: 1
    Dernier message: 29/05/2014, 17h43
  3. Web services avec apache CXF
    Par bendf82 dans le forum Services Web
    Réponses: 1
    Dernier message: 18/08/2008, 11h14

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