I have a xml schema (xsd) file which is inside a jar file that will be included in the runtime class path. In my Wsdl i need to import the schema by giving location inside the jar file.
I try to use XML catalog but the server i use (websphere) does not resolve xml catalog reference.
We were facing a similar issue where the JAR containing the XSD was getting added to the classpath and we had to refer to it from WSDL using schemaLocation. Our project was maven based, so we used the unpack goal of maven-dependency-plugin to download the file to the resources folder before compilation.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>${version}</version>
<outputDirectory>${basedir}/src/main/resources/xsd</outputDirectory>
<includes>ToDownload.xsd</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
This results in the xsd getting downloaded to the resources directory in a folder named xsd.
In WSDL schemaLocation="xsd/ToDownload.xsd".
This ensures that during compilation the WSDL will refer to the XSD which has been downloaded and locally available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With