How to change the encoding of created wsimport files?

I am using the wsimport ant JAX-WS task to generate sources based on some wsdl.

However, these generated sources appear to be UTF-8 encoded. Is there a way to change the encoding of files caused by the wsimport task?

+4
source share
4 answers

This is somewhat poorly documented. WSImport uses XJC (from JAXB) to create Java files, and the documentation here indicates that it is enough to change the character encoding in the XML file (although I have not tried this). If you are happy with running JAXB manually, you can also configure it using the JAXB_ENCODING property in JAXBContext.

+3
source

:

JAVA_TOOL_OPTIONS - - Dfile.encoding=UTF8

:

set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

c:>wsimport -keep ... file.wsdl

JAVA_TOOL_OPTIONS: -Dfile.encoding = UTF8 WSDL...

...

+2

Set the environment variable from JAVA_TOOL_OPTIONSto-Dfile.encoding=UTF8

An example from the terminal in windows:

set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

c:>wsimport -keep ... file.wsdl

Picked up `JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8`
parsing WSDL...

Generating code...
0
source

In wsimport 2.2.9, there is an option in JDK 8 -encodingthat you can use to do this. For example:

wsimport -keep -s c:\path\to\src c:\wsdl\myService.wsdl -encoding cp1252

I can not find this option in either wsimport 2.1.6 (JDK 6) or 2.2.4-b01 (JDK 7).

0
source

Source: https://habr.com/ru/post/1725283/


All Articles