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

Spring Java Discussion :

Problèmes ave un exemple SpringWS [Web Services]


Sujet :

Spring Java

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut Problèmes ave un exemple SpringWS
    Bonjour;
    Mon projet consiste à travailler avec Spring ws, malheureusement c'est la première fois que j'utilise les web services.
    j'ai suivi le tutorial http://hikage.developpez.com/java/tu...ice/spring-ws/mais je retrouve des problèmes:
    1- D'abord dans mon endPoint j'arrive pas à saisir cette partie
    "Traduction traduction = traductionService.traduitTexte(langueOrigine, langueDestination,
    texteOriginal);"
    2- J'ai lu dans le tuto du site http://static.springsource.org/sprin.../tutorial.html que le wsdl sera généré "we don't need to write a WSDL ourselves; Spring-WS can generate one for us based on some conventions", j'ai essayé mais il me génère pas le wsdl.
    3-Finalement, j'ai essayé d'écrire mon ficheir tradution.wsdl je ne sais aps si c'est correct ou pas, bref je vous mets mon code:
    TraductionEndPoint.java:
    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
    package com.hr.ws;
     
    import org.springframework.ws.server.endpoint.AbstractJDomPayloadEndpoint;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.Namespace;
    import org.jdom.xpath.XPath;
     
    import com.hr.service.TraductionService;
     
    public class TraductionEndpoint extends AbstractJDomPayloadEndpoint {
     
     
    private XPath langueOrigineExpression;
    private XPath langueDestinationExpression;
    private XPath texteExpression;
    private TraductionService traductionService;
     
    public TraductionEndpoint(TraductionService traductionService) throws JDOMException {
    		this.traductionService=traductionService;
    		Namespace namespace = Namespace.getNamespace("traduction", "http://www.hikage.be/schema/traduction");
    		langueOrigineExpression=XPath.newInstance("//traduction:langueOrigine");
    		langueOrigineExpression.addNamespace(namespace);
    		langueDestinationExpression = XPath.newInstance("//traduction:langueDestination");
    		langueDestinationExpression.addNamespace(namespace);
    		texteExpression =XPath.newInstance("//traduction:TraductionRequest/traduction:texte");
    		texteExpression.addNamespace(namespace);
    }
     
     
    protected Element invokeInternal(Element traductionRequest) throws Exception {
           String langueOrigine = langueOrigineExpression.valueOf(traductionRequest);
    	   String langueDestination = langueDestinationExpression.valueOf(traductionRequest);
    	   String texteOriginal = texteExpression.valueOf(traductionRequest);
    	   traductionService.traduitTexte(langueOrigine, langueDestination,texteOriginal);
     
            return null;  
            }
     
     
    	/*
    	// Création de la réponse
    	Namespace namespace = Namespace.getNamespace("traduction", "http://www.hikage.be/schema/traduction");
    	Element root = new Element("TraductionResponse", namespace);
    	Element auteur = new Element("auteur", namespace);
    	auteur.setText(traductionService.getAuteur());
    	Element texteTraduit = new Element("texte", namespace);
    	texteTraduit.setText(traductionService.getTexte());
    	root.addContent(auteur);
    	root.addContent(texteTraduit);
    	return root;
    	}*/
    }
    traduction.wsdl

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                      xmlns:schema="http://www.hikage.be/schema/traduction"
                      xmlns:tns="http://www.hikage.be/definitions"
                      targetNamespace="http://www.hikage.be/definitions">
        <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <xsd:import namespace="http://www.hikage.be/schema/traduction" schemaLocation="traduction.xsd"/>
            </xsd:schema>
        </wsdl:types>
        <wsdl:message name="TraductionRequest">
            <wsdl:part element="schema:TraductionRequest" name="TraductionRequest">
            </wsdl:part>
        </wsdl:message>
        <wsdl:message name="TraductionResponse">
            <wsdl:part element="schema:TraductionResponse" name="TraductionResponse">
            </wsdl:part>
        </wsdl:message>
        <wsdl:portType name="traduction">
            <wsdl:operation name="Holiday">
                <wsdl:input message="tns:TraductionRequest" name="TraductionRequest">
                </wsdl:input>
                <wsdl:output message="tns:TraductionResponse" name="TraductionResponse">
                </wsdl:output>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="traductionBinding" type="tns:traduction">
            <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="Holiday">
                <soap:operation soapAction=""/>
                <wsdl:input name="TraductionRequest">
                    <soap:body use="literal"/>
                </wsdl:input>
                <wsdl:output name="TraductionResponse">
                    <soap:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="TraductionService">
            <wsdl:port binding="tns:traductionBinding" name="traductionPort">
                <soap:address location="http://localhost:8080/traductionService/"/>
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    traduction.xsd
    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
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:traduction="http://www.hikage.be/schema/traduction"
    targetNamespace="http://www.hikage.be/schema/traduction" elementFormDefault="qualified">
    <xs:element name="TraductionRequest" type="traduction:TraductionRequestType"/>
    <xs:element name="TraductionResponse" type="traduction:TraductionResponseType"/>
    <xs:complexType name="TraductionRequestType">
    <xs:sequence>
    <xs:element name="langueOrigine" type="xs:string"/>
    <xs:element name="langueDestination" type="xs:string"/>
    <xs:element name="texte" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TraductionResponseType">
    <xs:sequence>
    <xs:element name="auteur" type="xs:string"/>
    <xs:element name="texte" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    traductionService.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    package com.hr.service;
     
     
    public interface TraductionService {
     
            void traduitTexte(String langueOrigine, String langueDestination,String
        		texteOriginal);
     
    }

    Est ce que vous pouvez m'éclairer sur la partie "Création de la réponse" dans mon endPoint et voir sin monwsdl est correct!
    merci

  2. #2
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    bonjour,
    je pense que ton xsd est valide. Si tu postais la façon que tu utilise pour générer automatiquement le wsdl, on pourra peut etre t'aider?

    mais cela dépend de la version de spring. Je pense que c'est seulement avec la version 1.5 que c'est possible

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    je crée mon .war avec mvn install, une fois le war créée je l'importe dans eclipse, une fois tomcat démarré je tape

    http://localhost:8080/spring-wsTest/traduction.wsdl
    (spring-wsTest est le nom de mon projet)
    g une exception:
    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
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
     
    Etat HTTP 500 - 
     
    --------------------------------------------------------------------------------
     
    type Rapport d'exception
     
    message 
     
    description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
     
    exception 
     
    javax.servlet.ServletException: "Servlet.init()" pour la servlet spring-ws a généré une exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	java.lang.Thread.run(Unknown Source)
     
     
    cause mère 
     
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'traductionEndpoint' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hr.ws.TraductionEndpoint]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.hr.ws.TraductionEndpoint.<init>()
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:451)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:332)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:266)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:236)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	java.lang.Thread.run(Unknown Source)
     
     
    cause mère 
     
    org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hr.ws.TraductionEndpoint]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.hr.ws.TraductionEndpoint.<init>()
    	org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:58)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:752)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:717)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:332)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:266)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:236)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	java.lang.Thread.run(Unknown Source)
     
     
    cause mère 
     
    java.lang.NoSuchMethodException: com.hr.ws.TraductionEndpoint.<init>()
    	java.lang.Class.getConstructor0(Unknown Source)
    	java.lang.Class.getDeclaredConstructor(Unknown Source)
    	org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:752)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:717)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:332)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:266)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:236)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	java.lang.Thread.run(Unknown Source)
     
     
    note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/5.5.25.
     
     
    --------------------------------------------------------------------------------
     
    Apache Tomcat/5.5.25

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    voici mon spring-ws-servlet.xml je pense que c'est ici le problème, il arrive pas à créer le bean traductionEndpoint
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
     
    <bean id="traductionEndpoint" class="com.hr.ws.TraductionEndpoint">
    <property name="traductionService" ref="traductionService"/>
    </bean>
    <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    	<property name="mappings">
    		<props>
    			<prop key="{http://www.hikage.be/schema/traduction}TraductionRequest">traductionEndpoint</prop>
    		</props>
    		</property>
    	<property name="interceptors">
    		<list>
    			<bean
    class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"></bean>
    </list>
    </property>
    </bean>
    <bean id="traduction" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">   
      <property name="builder">
        <bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
          <property name="schema" value="/WEB-INF/traduction.xsd"/>                                  
          <property name="portTypeName" value="traduction"/>                              
          <property name="locationUri" value="http://localhost:8080/traductionService/"/>       
     
        </bean>
      </property>
    </bean>
     
    </beans>

  5. #5
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    le problèm pour l'instant est dans ta config.
    1-ton traduction service n'est pas déclarer.
    2- ton traduction est déclarer dans le constructeur alors que ta config utilise property ce qui signifie que tu est en train de' l'injecter avec un setter.

    au lieu de property tu doit utiliser la balise <constructor-arg>

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    merci g enfin généré le fichier traduction.wsdl.
    g ajouté la classe StubtraductionService
    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
    package com.hr.service;
     
     
     
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class StubtraductionService implements TraductionService {
     
    	private static final Log logger = LogFactory.getLog(StubtraductionService.class);
     
    	public void traduitTexte(String langueOrigine, String langueDestination,String
        		texteOriginal){
    		logger.info("Traduction du texte " + texteOriginal + "de la langue" + langueOrigine + " en " + langueDestination );
     
    	}
     
        }
    et voici traduction.wsdl généré:
    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
     
    <?xml version="1.0" encoding="UTF-8" ?> 
     <wsdl:definitions xmlns:schema="http://www.hikage.be/schema/traduction" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.hikage.be/schema/traduction">
     <wsdl:types>
     <xs:schema xmlns:traduction="http://www.hikage.be/schema/traduction" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.hikage.be/schema/traduction">
      <xs:element name="TraductionRequest" type="traduction:TraductionRequestType" /> 
      <xs:element name="TraductionResponse" type="traduction:TraductionResponseType" /> 
     <xs:complexType name="TraductionRequestType">
    <xs:sequence>
      <xs:element name="langueOrigine" type="xs:string" /> 
      <xs:element name="langueDestination" type="xs:string" /> 
      <xs:element name="texte" type="xs:string" /> 
      </xs:sequence>
      </xs:complexType>
    <xs:complexType name="TraductionResponseType">
    <xs:sequence>
      <xs:element name="auteur" type="xs:string" /> 
      <xs:element name="texte" type="xs:string" /> 
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      </wsdl:types>
      <wsdl:message name="TraductionRequest">
      <wsdl:part element="schema:TraductionRequest" name="TraductionRequest" /> 
      </wsdl:message>
    <wsdl:message name="TraductionResponse">
      <wsdl:part element="schema:TraductionResponse" name="TraductionResponse" /> 
      </wsdl:message>
     <wsdl:portType name="traduction">
     <wsdl:operation name="Traduction">
      <wsdl:input message="schema:TraductionRequest" name="TraductionRequest" /> 
      <wsdl:output message="schema:TraductionResponse" name="TraductionResponse" /> 
      </wsdl:operation>
      </wsdl:portType>
     <wsdl:binding name="traductionBinding" type="schema:traduction">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="Traduction">
      <soap:operation soapAction="" /> 
     <wsdl:input name="TraductionRequest">
      <soap:body use="literal" /> 
      </wsdl:input>
     <wsdl:output name="TraductionResponse">
      <soap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
     <wsdl:service name="traductionService">
     <wsdl:port binding="schema:traductionBinding" name="traductionPort">
      <soap:address location="http://localhost:8080/traductionService/" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
    mais le problème mnt c que quand je teste mon web service, il m'affiche:
    IWAB0135E An unexpected error has occurred.
    404
    /traductionService/

    Est ce que vous voyez de quoi s'agit-il?

  7. #7
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    la génération du wsdl est totalement indépendante du service càd tu peux génerer ton wsdl sans meme avoir écrit ton service et son endpoint.

    l'erreur 404 signifie généralement une ressource indisponible qui peut etre par exemple une url mal former vérifie ton url, et ton code.
    et regarde le log c'est souvent là ou se trouve la réponse et non pas la réponse du navigateur

  8. #8
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut IWAB0135E An unexpected error has occurred.
    Salut, c encore moi

    J'essaye depuis hier mais je ne vois toujours pas où est le problème:
    voici le contenu de mon projet:
    TraductionEndpoint.java
    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
     
    package com.hr.ws;
     
    import org.springframework.ws.server.endpoint.AbstractJDomPayloadEndpoint;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.Namespace;
    import org.jdom.xpath.XPath;
     
    import com.hr.service.TraductionService;
     
    public class TraductionEndpoint extends AbstractJDomPayloadEndpoint {
     
     
    private XPath langueOrigineExpression;
    private XPath langueDestinationExpression;
    private XPath texteExpression;
    private TraductionService traductionService;
     
     
     
    public TraductionEndpoint(TraductionService traductionService) throws JDOMException {
    		this.traductionService=traductionService;
    		Namespace namespace = Namespace.getNamespace("traduction", "http://com.hr.ws/schema/traduction");
    		langueOrigineExpression=XPath.newInstance("//traduction:langueOrigine");
    		langueOrigineExpression.addNamespace(namespace);
    		langueDestinationExpression = XPath.newInstance("//traduction:langueDestination");
    		langueDestinationExpression.addNamespace(namespace);
    		texteExpression =XPath.newInstance("//traduction:TraductionRequest/traduction:texte");
    		texteExpression.addNamespace(namespace);
    }
     
     
    protected Element invokeInternal(Element traductionRequest) throws Exception {
           String langueOrigine = langueOrigineExpression.valueOf(traductionRequest);
    	   String langueDestination = langueDestinationExpression.valueOf(traductionRequest);
    	   String texteOriginal = texteExpression.valueOf(traductionRequest);
    	   traductionService.traduitTexte(langueOrigine, langueDestination,texteOriginal);
     
            return null;  
            }
     
     
    	/*
    	// Création de la réponse
     
    	*/
    }
    TraductionService.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    package com.hr.service;
     
    public interface TraductionService {
     
     
        void traduitTexte(String langueOrigine, String langueDestination,String
        		texteOriginal);
     
    }
    StubtraductionService.java
    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
    package com.hr.service;
     
     
     
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
     
    public class StubtraductionService implements TraductionService {
     
    	private static final Log logger = LogFactory.getLog(StubtraductionService.class);
     
    	public void traduitTexte(String langueOrigine, String langueDestination,String
        		texteOriginal){
    		logger.info("Traduction du texte " + texteOriginal + "de la langue" + langueOrigine + " en " + langueDestination );
     
    	}
     
     
     
     
        }
    spring-ws-servlet.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
    27
    28
    29
    30
    31
    32
    33
    34
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
     
    <bean id="traductionEndpoint" class="com.hr.ws.TraductionEndpoint">
    <constructor-arg ref="hrService"/>
     
    </bean>
    <bean id="hrService" class="com.hr.service.StubtraductionService"/>
    <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    	<property name="mappings">
    		<props>
    			<prop key="{http://com.hr.ws/schema/traduction}TraductionRequest">traductionEndpoint</prop>
    		</props>
    		</property>
    	<property name="interceptors">
    		<list>
    			<bean
    class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"></bean>
    </list>
    </property>
    </bean>
    <bean id="traduction" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">   
      <property name="builder">
        <bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
          <property name="schema" value="/WEB-INF/traduction.xsd"/>                                  
          <property name="portTypeName" value="HumanResource"/>                              
          <property name="locationUri" value="http://localhost:8080/traductionService/"/>       
     
        </bean>
      </property>
    </bean>
     
    </beans>

    traduction.wsdl
    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
     
    <?xml version="1.0" encoding="UTF-8" ?> 
    <wsdl:definitions xmlns:schema="http://com.hr.ws/schema/traduction" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://com.hr.ws/schema/traduction">
     <wsdl:types>
     <xs:schema xmlns:traduction="http://com.hr.ws/schema/traduction" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://com.hr.ws/schema/traduction">
      <xs:element name="TraductionRequest" type="traduction:TraductionRequestType" /> 
      <xs:element name="TraductionResponse" type="traduction:TraductionResponseType" /> 
     <xs:complexType name="TraductionRequestType">
     <xs:sequence>
      <xs:element name="langueOrigine" type="xs:string" /> 
      <xs:element name="langueDestination" type="xs:string" /> 
      <xs:element name="texte" type="xs:string" /> 
      </xs:sequence>
      </xs:complexType>
     <xs:complexType name="TraductionResponseType">
     <xs:sequence>
      <xs:element name="auteur" type="xs:string" /> 
      <xs:element name="texte" type="xs:string" /> 
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      </wsdl:types>
     <wsdl:message name="TraductionResponse">
      <wsdl:part element="schema:TraductionResponse" name="TraductionResponse" /> 
      </wsdl:message>
     <wsdl:message name="TraductionRequest">
      <wsdl:part element="schema:TraductionRequest" name="TraductionRequest" /> 
      </wsdl:message>
     <wsdl:portType name="HumanResource">
     <wsdl:operation name="Traduction">
      <wsdl:input message="schema:TraductionRequest" name="TraductionRequest" /> 
      <wsdl:output message="schema:TraductionResponse" name="TraductionResponse" /> 
      </wsdl:operation>
      </wsdl:portType>
     <wsdl:binding name="HumanResourceBinding" type="schema:HumanResource">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
     <wsdl:operation name="Traduction">
      <soap:operation soapAction="" /> 
     <wsdl:input name="TraductionRequest">
      <soap:body use="literal" /> 
      </wsdl:input>
     <wsdl:output name="TraductionResponse">
      <soap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
     <wsdl:service name="HumanResourceService">
     <wsdl:port binding="schema:HumanResourceBinding" name="HumanResourcePort">
      <soap:address location="http://localhost:8080/traductionService/" /> 
      </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    traduction.wsd
    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
     
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:traduction="http://com.hr.ws/schema/traduction"
    targetNamespace="http://com.hr.ws/schema/traduction" elementFormDefault="qualified">
    <xs:element name="TraductionRequest" type="traduction:TraductionRequestType"/>
    <xs:element name="TraductionResponse" type="traduction:TraductionResponseType"/>
    <xs:complexType name="TraductionRequestType">
    <xs:sequence>
    <xs:element name="langueOrigine" type="xs:string"/>
    <xs:element name="langueDestination" type="xs:string"/>
    <xs:element name="texte" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TraductionResponseType">
    <xs:sequence>
    <xs:element name="auteur" type="xs:string"/>
    <xs:element name="texte" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">
     
        <display-name>Archetype Created Web Application</display-name>
     
        <servlet>
            <servlet-name>spring-ws</servlet-name>
            <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
        </servlet>
     
        <servlet-mapping>
            <servlet-name>spring-ws</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
     
    </web-app>

    je teste mon wsdl avec soapUI et j'obtiens cette erreur:

    Etat HTTP 404 - /traductionService/Rapport d'état
    La ressource demandée (/traductionService/) n'est pas disponible

    Apache Tomcat/5.5.25
    org.apache.xmlbeans.XmlException: error:
    does not close tag


    Il ne retrouve pas mon service mais je vois pas où se trouve l'erreur!!

  9. #9
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    bonjour,
    est-ce que tu peux poster le chemin absolue de ton projet(depuis la racine jusqu'au dossier sous tomcat)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    org.apache.xmlbeans.XmlException: error:
    does not close tag
    appremment il te manque un ">" mais je ne sais pas ou
    aussi ajoute ceci a ton web.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <servlet-mapping>
    		<servlet-name>le nom de ta servlet</servlet-name>
    		<url-pattern>*.wsdl</url-pattern>		
    	</servlet-mapping>

  10. #10
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    ton wsdl est -il générer automatiquement?
    si oui dans soapui tu n'as qu'à lui donner l'url et il s'occupe du reste.
    sinon le problème est dans ton wsdl

  11. #11
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    merci aymen d'avoir répondu, j'ai reglé le problème, j'avais commis une erreur dans le chemin; bref je n'ai plus cette erreur, mnt quand je teste avec soap, il ne m'affiche rien, si j'ai bien saisi normalement il doit m'afficher le message que j'ai mis dans ma classe StubtraductionService
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    public void traduitTexte(String langueOrigine, String langueDestination,String texteOriginal){
    		logger.info("Traduction du texte " + texteOriginal + "de la langue" + langueOrigine + " en " + langueDestination );
     
    	}

    voici le log de soapUI
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:Finding importer for {http://com.hr.ws/schema/traduction}TraductionBinding
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:Importing binding {http://com.hr.ws/schema/traduction}TraductionBinding
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:importing endpoint http://localhost:8080/spring-wsTest/traductionService/
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:importing operation Traduction
    Fri Apr 24 10:27:18 GMT+01:00 2009:DEBUG:Loading definition from cache
    Fri Apr 24 10:27:18 GMT+01:00 2009:DEBUG:Returning baseInputSource [file:C:\DEV\Project\spring-wsTest\WebContent\WEB-INF\traduction.wsdl]
    Fri Apr 24 10:27:18 GMT+01:00 2009:DEBUG:Loaded definition: ok
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:Loading schema types from [file:C:\DEV\Project\spring-wsTest\WebContent\WEB-INF\traduction.wsdl]
    Fri Apr 24 10:27:18 GMT+01:00 2009:INFO:Getting schema file:C:\DEV\Project\spring-wsTest\WebContent\WEB-INF\traduction.wsdl
    Fri Apr 24 10:27:28 GMT+01:00 2009:INFO:Got response for [TraductionBinding.Traduction:Request 1] in 1668ms (0 bytes)
    Fri Apr 24 11:06:49 GMT+01:00 2009:INFO:Got response for [TraductionBinding.Traduction:Request 1] in 7ms (0 bytes)
    et si je teste avec Eclipse, j'obtiens cette erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    The SOAP response failed schema validation. Please switch to the source view for the SOAP response in XML format

  12. #12
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    Citation Envoyé par aymen83 Voir le message
    ton wsdl est -il générer automatiquement?
    si oui dans soapui tu n'as qu'à lui donner l'url et il s'occupe du reste.
    sinon le problème est dans ton wsdl

    oui il est généré automatiquement et j'ai testé avec soap, pour l'instant j'ai plus d'erreur mais il m'affiche rien, je t'ai expliqué juste dans mon derneir post et merci encore

  13. #13
    Membre actif Avatar de aymen83
    Inscrit en
    Décembre 2007
    Messages
    271
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 271
    Points : 268
    Points
    268
    Par défaut
    bon, tout ce qui se rapporte à la configuration est réglé enfin normalement. Maintenant le problème est dans ta logique métier.

    bonne chance

  14. #14
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2009
    Messages : 48
    Points : 20
    Points
    20
    Par défaut
    est ce que tu peux me dire dans soapaction ce que je dois mettre???

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [FOP] Problème avec les exemples fournis
    Par Androrion dans le forum XML/XSL et SOAP
    Réponses: 10
    Dernier message: 22/08/2006, 14h54
  2. problème ave LEFT JOIN dans MySql
    Par lm0210 dans le forum Requêtes
    Réponses: 3
    Dernier message: 16/05/2006, 19h46
  3. [68k] Problème sur un exemple de code
    Par jib2b dans le forum Autres architectures
    Réponses: 2
    Dernier message: 19/04/2006, 23h10
  4. Problème ave Bulk Insert
    Par bubi dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 24/11/2005, 15h41
  5. Problème ave cl'option "Stop Build"
    Par boulette18 dans le forum MFC
    Réponses: 2
    Dernier message: 03/10/2005, 11h52

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