Code generation from WSDL using XML Catalog
Is there any tool for generating Java code from WSDL using X开发者_JS百科ML Catalogs? The problem is that I have wsdl files that import XML schemas which also import other schemas and the schemas are not available at schemaLocation url. That is why code generation fails. If a tool was able to use XML Catalog this problem would be solved without modifying each schemaLocation in each WSDLs and schemas.
I have tried Eclipse and Netbeans plugins but both failed. In Eclipse and Netbeans I have configured alternative schema locations by using XML Catalog and so they can validate WSDL files without error. However, when they generate code from wsdl they fail.
Just found that JBoss's wsconsume tool is able to consume XML Catalogs for entity resolution and it works fine.
http://community.jboss.org/wiki/JBossWS-wsconsume
Just for the record: i've set up a small exemple project on Github that uses an XML schema. it may be of any help: https://github.com/fmarot/xml-mapping-tutorial Be sure to check its wiki too in order to have an overview: https://github.com/fmarot/xml-mapping-tutorial/wiki
The WSDL has to be valid without the use of XML catalogs, or clients consuming that WSDL will not be able to consume it.
Of course, if you will never use any clients not running on the JBoss platform, then you'll be fine.
Meanwhile, I found an other solution that fits the best to my needs. There is a maven plugin called jaxws-maven-plugin that is also able to handle XMLCatalogs when generating sources from wsdl.
https://jax-ws-commons.dev.java.net/jaxws-maven-plugin/
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>id1</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<verbose>true</verbose>
<keep>true</keep>
<catalog>${basedir}/src/main/resources/catalog.xml</catalog>
<packageName>org.example</packageName>
<wsdlDirectory>
${basedir}/src/main/resources/contracts/wsdl/ExampleService/1
</wsdlDirectory>
<wsdlFiles>
<wsdlFile>ExampleService_1_0.wsdl</wsdlFile>
</wsdlFiles>
<xadditionalHeaders>false</xadditionalHeaders>
</configuration>
</execution>
</executions>
<configuration>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
</dependency>
</dependencies>
精彩评论