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