Table of Contents |
---|
Introduction
CXF includes a Maven plugin which can generate java artifacts from WSDL. Here is a simple example:
...
Code Block | ||
---|---|---|
| ||
<plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <version>${cxf.version}</version> <configuration> <fork>once</fork> <additionalJvmArgs>-Djava.endorsed.dirs=${project.build.directory}/endorsed</additionalJvmArgs> <!-- rest of the normal codegen configuration options --> </configuration> <dependencies> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>2.2.11</version> </dependency> </dependencies> </plugin> |
Reading external DTDs
More recent versions of XML Schema will throw an exception by default if the schema has an external DTD. For example:
[Fatal Error] xmldsig-core-schema.xsd:10:5: External DTD: Failed to read external DTD 'XMLSchema.dtd', because 'http' access is not allowed due to restriction set by the accessExternalDTD property.
If you wish to allow external DTDs then it's possible to do this via the the <additionalJvmArgs>' configuration switch as follows:
Code Block |
---|
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<fork>once</fork>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/org/apache/cxf/wsn/wsdl/wsn.wsdl</wsdl>
<extraargs>
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
<additionalJvmArgs>-Djavax.xml.accessExternalDTD=all</additionalJvmArgs>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin> |
Other configuration options
...