Although we would recommend using Maven, see the antbuild sample in the CXF distribution for an example of using Ant to create a CXF project.
JAXWS Customization
The default JAX-WS frontend created by wsdl2java can be customized by using a customization binding file. For an example, see theasync_binding.xml file in samples/jaxws_async – if specified when running wsdl2java, it will generate asynchronous methods in the SEI.
Q: What if I want to change the generated SEI name
A: We don't have a command-line option to do this, but you can have a binding file like the following snippet to achieve this goal
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="hello_world.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
Q: How do I pass the binding file to wsdl2java
A: If you are using wsdl2java via command line tool:
wsdl2java HelloWorld.wsdl -b my_binding.xml
For Ant, follow the example above on how to add "-b" and "my_binding.xml" as arg elements.
For Maven see cxf-codegen-plugin
Q: How to map xsd:dateTime to java.util.Date
Well, people don't like the XMLGregorianCalendar which is the default mapping from the xsd:dateTime (xsd:time and xsd:date as well),
We can use the jaxws customization to change the default mapping, here are some sample binding files
If you have schema inside the wsdl, here is the binding file you can use:
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
If you want to use java.util.Calendar, just change the org.apache.cxf.tools.common.DataTypeAdapter to javax.xml.bind.DatatypeConverter, and change the name value to "java.util.Calendar"
If your schema is out of wsdl, here is an example you can try:
xmlns:xs="http://www.w3.org/2001/XMLSchema">
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
Q: How can I switch my generated web service method calls from wrapper style to non wrapper-style (or vice-versa)
A: Create an external binding file and set the value of
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="your.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
Alternatively you can embed this instruction within the WSDL file directly, as the immediate child of the wsdl:portType:
... other binding settings if needed ...
...
Note: The meaning of "wrapper-style" and "non-wrapper style" as defined in the JAX-WS 2.1 specification can be counterintuitive. Wrapper-style indicates that each data eleme