В приложении Spring Boot я использую maven-jaxb2-plugin для генерации классов из файла WSDL:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>AUTODETECT</schemaLanguage>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
<generatePackage>pl.pantuptus.app.integration</generatePackage>
</configuration>
</plugin>
Файл WSDL содержит поле sales , определенное как:
<s:element minOccurs="1" maxOccurs="1"
name="sales" type="s:decimal" />
, который преобразуется maven-jaxb2-plugin в свойство BigDecimal сгенерированного класса:
@XmlElement(name = "sales", required = true)
protected BigDecimal sales;
Я настраиваю JAXB Marshaller явно в компоненте конфигурации:
@Configuration
public class IntegrationConfig {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("pl.pantuptus.app.integration");
return marshaller;
}
@Bean
public MyClient myClient(Jaxb2Marshaller marshaller) {
MyClient client = new MyClient();
client.setDefaultUri("http://localhost:8080/ws");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
Моя проблема в том, что когда я вызываю конечную точку WS с клиента:
getWebServiceTemplate().marshalSendAndReceive(url, request)
Я получаю объект с null значением sales property.
Я полагаю, что JAXB не может правильно проанализировать это свойство, поскольку в ответе используется запятый формат.
<sales>23 771,08</sales>
И тут возникает вопрос: как я могу сказать Jaxb2Marshaller (или любой другой реализации Marshaller), как преобразовать такую строку в BigDecimal?