Here is an excerpt from the my OSRMResponseDto.xsd:
<xsd:complexType name="OSRMResponseDto">
<xsd:sequence>
<xsd:element name="route_geometry" type="xsd:string"/>
<xsd:element name="route_name" type="xsd:string"/>
<xsd:element name="status" type="xsd:long"/>
<xsd:element name="status_message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
binding.xjb:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
<jaxb:globalBindings underscoreBinding="asCharInWord"/>
</jaxb:bindings>
The issue is that maven generates class with fields like:
@XmlElement(name = "route_geometry", namespace = "http://osrmresponse.generated.core", required = true)
protected String route_Geometry;
@XmlElement(name = "route_name", namespace = "http://osrmresponse.generated.core", required = true)
protected String route_Name;
@XmlElement(namespace = "http://osrmresponse.generated.core")
protected long status;
@XmlElement(name = "status_message", namespace = "http://osrmresponse.generated.core", required = true)
protected String status_Message;
as you can see here, it uppercases the second word and that's why gson could not convert output response from the OSRM server to my DTO class. How to make fields the same as in the .xsd source?
UPD1: maven plugin configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>gpx-xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/main/xsd/gpx/schema</bindingDirectory>
<clearOutputDir>false</clearOutputDir>
<npa>true</npa>
<schemaDirectory>${basedir}/src/main/xsd/gpx/schema</schemaDirectory>
<target>2.0</target>
<extension>true</extension>
</configuration>
</execution>
<execution>
<id>interfaces-xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/main/xsd/interfaces</bindingDirectory>
<clearOutputDir>false</clearOutputDir>
<npa>true</npa>
<schemaDirectory>${basedir}/src/main/xsd/interfaces</schemaDirectory>
<target>2.0</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>
</dependencies>
<configuration>
<!--
Package name of the generated sources.
-->
<packageName>core.generated</packageName>
<!--
Copy all source XSDs into the generate artifact.
Place them at the supplied xsdPathWithinArtifact, that is within the given directory.
-->
<xsdPathWithinArtifact>src/main/java/core/xsds</xsdPathWithinArtifact>
</configuration>
</plugin>