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 :

CXF et Tomcat


Sujet :

Services Web Java

  1. #1
    Membre averti
    Inscrit en
    Mars 2005
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 43
    Par défaut CXF et Tomcat
    Bonjour

    J’ai crée un web Service a l'aide de CXF, comme mentionné dans ce tutorial http://www.theasolutions.com/tutoria...attachment.jsp
    J’ai testé mon web service via la classe ci-dessous (fournit par Apache) et ça marche très bien
    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 demo.hw.server;
     
    import javax.xml.ws.Endpoint;
     
    public class Server {
     
        protected Server() throws Exception {
            // START SNIPPET: publish
            System.out.println("Starting Server");
            HelloWorldImpl implementor = new HelloWorldImpl();
           String address = "http://localhost:8080/cxf1/services/UploadResumeWS" ;
            Endpoint.publish(address, implementor);
            // END SNIPPET: publish
        }
     
        public static void main(String args[]) throws Exception {
            new Server();
            System.out.println("Server ready...");
     
            Thread.sleep(5 * 60 * 1000);
            System.out.println("Server exiting");
            System.exit(0);
        }
    }
    Par contre quand je déployer mon web service dans Tomcat et je veux le tester je reçoit l’exception suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    org.apache.cxf.phase.PhaseInterceptorChain doIntercept
    INFO: Interceptor has thrown exception, unwinding now Could not send Message.
    Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could 
    not send Message.
    	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
    	at $Proxy46.add(Unknown Source)
    Pourquoi cette exception? je dois générer et déployer le WSDL aussi ?( ce n’ai pas indiqué dans le tutorial)

  2. #2
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Normalement Tomcat deploie le wsdl "tout seul"

    Comment as-tu mis cela en oeuvre dans ton web.xml ?

  3. #3
    Membre averti
    Inscrit en
    Mars 2005
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 43
    Par défaut
    voila mon Web.xml
    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
    <?xml version="1.0"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
     
    <web-app>
      <display-name>cxf1</display-name>
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:com/test/cxf.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>/services/*</url-pattern>
      </servlet-mapping>
    </web-app>
    et voila mon cxf.xml
    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
    <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:jaxws="http://cxf.apache.org/jaxws"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
     					http://www.springframework.org/schema/beans/spring-beans.xsd
     					http://cxf.apache.org/jaxws
     					http://cxf.apache.org/schemas/jaxws.xsd">
     
      <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" />
      <jaxws:endpoint id="uploadresume"
                      implementor="com.test.TestCxfServiceImpl"
                      address="/UploadResumeWS">
                      <jaxws:properties>
          <entry key="mtom-enabled" value="true"/>
        </jaxws:properties>	
        </jaxws:endpoint>
    </beans>

  4. #4
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Et quand tu fais l'url suivante dans ton navigateur:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <path-to-webapp>/UploadResumeWS
    Que se passe-t-il ?

    PS : path-to-webapp correspond à l'url de ton application

  5. #5
    Membre averti
    Inscrit en
    Mars 2005
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 43
    Par défaut
    404

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    type Rapport d'état
     
    message /cxf1/UploadResumeWS
     
    description La ressource demandée (/cxf1/UploadResumeWS) n'est pas disponible.

  6. #6
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    euh ?
    Tu as spécifié l'adresse de ton serveur avant ?

    genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    http://localhost:8080/cxf1/UploadResumeWS

  7. #7
    Membre averti
    Inscrit en
    Mars 2005
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 43
    Par défaut
    j'ai spécifié l'adresse dans la classe client
    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
    package com.test.client;
    
    
    /*import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;*/
    
    import org.apache.cxf.interceptor.LoggingInInterceptor;
    import org.apache.cxf.interceptor.LoggingOutInterceptor;
    import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
    
    import com.test.TestCxfService;
    
    
    public final class Client {
    
        private Client() {
    	
        } 
    
        public static void main(String args[]) throws Exception {
    
        	JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    
        	factory.getInInterceptors().add(new LoggingInInterceptor());
        	factory.getOutInterceptors().add(new LoggingOutInterceptor());
        	factory.setServiceClass(TestCxfService.class);
        	factory.setAddress
        	("http://localhost:8080/cxf1/services/UploadResumeWS");
        	TestCxfService client = (TestCxfService) factory.create();
    
        	
        	System.out.println("==>"+client.add(4,5));
        	
        	System.exit(0);
    
        }
    }

  8. #8
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Ta config devrait plutot ressembler a ca en fait :

    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
     
     
        <!-- The service bean -->
        <bean id="testCxfServiceImpl" class="com.test.TestCxfServiceImpl"/>
     
        <!-- 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="uploadresume"
                      implementorClass="com.test.TestCxfServiceImpl"
                      address="/UploadResumeWS">
         <jaxws:serviceFactory>
                <ref bean="jaxws-and-aegis-service-factory"/>
            </jaxws:serviceFactory>
        </jaxws:endpoint>

  9. #9
    Membre averti
    Inscrit en
    Mars 2005
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 43
    Par défaut
    Toujours

    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
    3 avr. 2009 15:31:28 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
    INFO: Interceptor has thrown exception, unwinding now Could not send Message.
    Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not send Message.
    	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
    	at $Proxy46.add(Unknown Source)
    	at com.test.client.Client.main(Client.java:33)
    Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
    	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
    	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
    	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:469)
    	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
    	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
    	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
    	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
    	... 2 more
    Caused by: java.io.IOException: Introuvable
    	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2026)
    	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1980)
    	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1905)
    	at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
    	at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:170)
    	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
    	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:600)
    	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    	... 8 more

Discussions similaires

  1. [CXF][Spring][Tomcat][Débutant] Créer un service REST
    Par cowa dans le forum Services Web
    Réponses: 5
    Dernier message: 31/10/2010, 12h20
  2. Comment installer le framework CXF sous Tomcat ?
    Par 2beornot2be dans le forum Services Web
    Réponses: 2
    Dernier message: 23/09/2009, 11h01
  3. [CXF] client web services sous tomcat
    Par j0hnmerrick dans le forum Services Web
    Réponses: 2
    Dernier message: 12/05/2009, 16h10
  4. [CXF] Déploiement WS sous Tomcat ou Weblo sans Spring
    Par goldest dans le forum Services Web
    Réponses: 0
    Dernier message: 29/07/2008, 14h37
  5. Réponses: 2
    Dernier message: 11/02/2008, 18h29

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