tell jaxb to not remove underscores
Example: NR_ROR should not become getNRROR but getNR_ROR.
Note: I believe that the less-mangled names are worth the "violation" of Java naming convention. TIA karolrvnCreate a custom binding and set "underscoreBinding" to "asCharInWord". One approach is to create a file called binding.xjb and use the -b flag to tell xjc where it is. Here's an example of what you'd put in binding.xml:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<jaxb:bindings schemaLocation="foobar.xsd">
<jaxb:globalBindings underscoreBinding="asCharInWord"/>
</jaxb:bindings>
</jaxb:bindings>
Have a look at the underscoreBinding that jaxb provides. See, for example, in the docs here -> http://java.sun.com/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html
I have never used it since I like camelCaseWords, but it sounds like it does what you are looking for.
I came here looking for how to do the same thing, with the additional qualification that the schema is embedded inside a WSDL. To do that, combine https://stackoverflow.com/a/6545815/4512591 with lreeder's answer above, changing:
schemaLocation="foobar.xsd"
to
wsdlLocation="foobar.wsdl"
Net result:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<jaxb:bindings wsdlLocation="foobar.wsdl">
<jaxb:globalBindings underscoreBinding="asCharInWord"/>
</jaxb:bindings>
</jaxb:bindings>
This is with the JAXWS Reference Implementation, at least.
精彩评论