Bonjour,

Je rencontre un problème très embêtant avec les accents lors de la réponse d'un webservice.

Toute mon appli est en ISO-8859-1 mais lorsque j'appelle mon webservice, il me dit que je suis en UTF-8

Voici mon code:

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
 
<wsdl:definitions name="enf_creation_dmp" targetNamespace="" xmlns="" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
       <schema xmlns="http://www.w3.org/2001/XMLSchema">
           <include schemaLocation="enf_dmp_creation0.3.xsd"/>
       </schema>
    </wsdl:types>
 
    <wsdl:message name="enf_dmp_creationInput">
        <wsdl:part element="enf_dmp_creation" name="body"/>
 
  </wsdl:message>
 
    <wsdl:message name="enf_dmp_creationOutput">
        <wsdl:part element="enf_dmp_creation" name="body"/>
 
  </wsdl:message>
 
    <wsdl:portType name="enf_creation_dmpPortType">
        <wsdl:operation name="enf_creation_dmp">
           <wsdl:input message="enf_dmp_creationInput"/>
           <wsdl:output message="enf_dmp_creationOutput"/>
        </wsdl:operation>
    </wsdl:portType>
 
    <wsdl:binding name="enf_creation_dmpBinding" type="enf_creation_dmpPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="enf_creation_dmp">
           <soap:operation soapAction="enf_creation_dmp"/>
           <wsdl:input>
               <soap:body use="literal" />
           </wsdl:input>
           <wsdl:output>
               <soap:body use="literal"/>
           </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
 
    <wsdl:service name="enf_creation_dmp">
        <wsdl:documentation>IB Soap service</wsdl:documentation>
        <wsdl:port binding="enf_creation_dmpBinding" name="enf_creation_dmpPort">
			<soap:address location="http://..."/>
			<http-conf:client ReceiveTimeout="300000" />
        </wsdl:port>
    </wsdl:service>
 
</wsdl:definitions>
Appel du webservice:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
...
try {
			// Serialization
			xmlMapper.writeObjectToXml(dmpCreation, filename);
 
			//Création de l'objet que l'on va envoyer au webservice
			EnfDmpCreation enfDmpCreation = new EnfDmpCreation();
			enfDmpCreation = (EnfDmpCreation) xmlMapper.readObjectFromXml(filename);
			//Appel du webservice
			Holder<EnfDmpCreation> holderEnfDmpCreation = new Holder<EnfDmpCreation>(enfDmpCreation);
			wsCreationDMP.enfCreationDmp(holderEnfDmpCreation);
 
...
Classe JAXB:
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
 
public void writeObjectToXml(Object object, String filename) throws IOException {
        FileOutputStream fos = null;
        try {
        	//On change l'encoding par défaut pour les accents
        	Map<String, String> marshallerProperties = new HashMap<String, String>();
    		marshallerProperties.put(Marshaller.JAXB_ENCODING, "ISO-8859-1");
    		jaxbMarshaller.setMarshallerProperties(marshallerProperties);
 
            fos = new FileOutputStream(filename);
            jaxbMarshaller.marshal(object, new StreamResult(fos));
            fos.close();
        } catch (XmlMappingException e) {
        	log.error("Xml-Serialization failed due to an XmlMappingException.", e);
        } catch (IOException e) {
        	log.error("Xml-Serialization failed due to an IOException.", e);
        } finally {
            if (fos != null) {
                fos.close();
            }
        }
    }
 
    public Object readObjectFromXml(String filename) throws IOException {
        FileInputStream fis = null;
        try {
        	//On change l'encoding par défaut pour les accents
        	Map<String, String> marshallerProperties = new HashMap<String, String>();
    		marshallerProperties.put(Marshaller.JAXB_ENCODING, "ISO-8859-1");
    		jaxbMarshaller.setMarshallerProperties(marshallerProperties);
 
            fis = new FileInputStream(filename);
            Object obj = jaxbMarshaller.unmarshal(new StreamSource(fis));
            fis.close();
            return obj;
        } catch (IOException e) {
        	log.error("Xml-Deserialization failed due to an IOException.", e);
        } finally {
            if (fis != null) {
                fis.close();
            }
        }
        return null;
    }
Et voici mes logs:
Infos: Outbound Message
---------------------------
ID: 2
Address: http://192.168.1.24:20210/IB/servlet...d=HELLODMP_XML
Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], Accept-Encoding=[ISO-8859-1], Accept-Language=[ISO-8859-1], Connection=[Keep-Alive], SOAPAction=["enf_creation_dmp"]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:enf_dmp_creation xmlns:ns2="http://cxf/" type="creation">...</ns2:enf_dmp_creation></soap:Body></soap:Envelope>
--------------------------------------
nov. 09, 2011 12:07:02 PM org.apache.cxf.interceptor.AbstractLoggingInterceptor log
Infos: Inbound Message
----------------------------
ID: 2
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml;charset=utf-8
Headers: {Accept=[text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2], Content-Length=[798], content-type=[text/xml;charset=utf-8], Date=[Wed, 09 Nov 2011 11:06:57 GMT], Root.Content-Type=[text/xml], Server=[Apache-Coyote/1.1]}
Payload: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><ns2:enf_dmp_creation xmlns:ns2="http://cxf/" type="creation">...</ns2:enf_dmp_creation></SOAP-ENV:Body></SOAP-ENV:Envelope>
--------------------------------------
Donc comment faire pour être en ISO-8859-1 et ainsi avoir mes accents?