views:

260

answers:

3

Is there any tool for generating Java code from WSDL using XML 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.

+1  A: 

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

Peter Miklos
A: 

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.

John Saunders
A: 

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>

Peter Miklos