Sreepad Chitragar
Sreepad Chitragar

Reputation: 193

How to solve the conflicts between the same classes getting generated under different folders but with the same package xmlns given in two WSDL files?

I have 2 WSDL's namely UserStore.wsdl and Authorization.wsdl with xmlns:ns="http://service.ws.um.carbon.wso2.org"

            <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
             <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <vmArgs>
                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                        </vmArgs>
                        <args>
                            <arg>-B-XautoNameResolution</arg>
                        </args>
                        <wsdlFiles>
                            <wsdlFile>RemoteAuthorizationManagerService.wsdl</wsdlFile>
                        </wsdlFiles>
                        <wsdlDirectory>${basedir}/src/main/wsdl</wsdlDirectory>
                        <staleFile>${project.build.directory}/jaxws/stale/RemoteAuthorizationManagerService.stale</staleFile>
                        <wsdlLocation>/META-INF/wsdl/RemoteAuthorizationManagerService.wsdl</wsdlLocation>
                    </configuration>
                    <id>wsimport-generate-RemoteAuthorizationManagerService</id>
                    <phase>generate-sources</phase>
                </execution>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <vmArgs>
                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                        </vmArgs>
                        <args>
                            <arg>-B-XautoNameResolution</arg>
                        </args>
                        <wsdlFiles>
                            <wsdlFile>RemoteUserStoreManagerService.wsdl</wsdlFile>
                        </wsdlFiles>
                        <wsdlDirectory>${basedir}/src/main/wsdl</wsdlDirectory>
                        <staleFile>${project.build.directory}/jaxws/stale/RemoteUserStoreManagerService.stale</staleFile>
                        <wsdlLocation>/META-INF/wsdl/RemoteUserStoreManagerService.wsdl</wsdlLocation>
                        <sourceDestDir>${project.build.directory}/generated-sources/xjc</sourceDestDir>
                        <compilerArgument>-proc:none</compilerArgument>
                    </configuration>
                    <id>wsimport-generate-RemoteUserStoreManagerService</id>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>javax.xml</groupId>
                    <artifactId>webservices-api</artifactId>
                    <version>1.4</version>
                </dependency>
            </dependencies>
            <configuration>
                <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport-wsdl</sourceDestDir>
                <xnocompile>true</xnocompile>
                <verbose>true</verbose>
                <extension>true</extension>
                <keep>true</keep>
                <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
                <compilerArgument>-proc:none</compilerArgument>
            </configuration>
            </plugin>

The root cause what we are facing is ObjectFactory classes are getting generated under different folders XJC and jaxws-wsimport-wsdl [as mentioned in sourceDestDir tag] but with the same package namely [org.wso2.carbon.um.ws.service.ObjectFactory] due to which compiler complains The type ObjectFactory is already defined and JAR file is not getting generated.

Also tried giving

    <compilerArgument>-proc:none</compilerArgument>

which didn't work.

We are not allowed to modify the WSDL's and needs to be resolved this problem.

Thanks in Advance.

Upvotes: 0

Views: 854

Answers (1)

jcompetence
jcompetence

Reputation: 8383

So my understand to your problem is that you want different packages to be defined?

To configure target packages using binding files:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
    version="2.1"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jaxb:bindings schemaLocation="a.xsd" node="//xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="org.ab.a"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>

https://github.com/highsource/maven-jaxb2-plugin/wiki/Configure-Target-Packages-in-Binding-Files#configure-target-packages-in-binding-files


You might be also able to use

<packageName>
The package in which the source files will be generated.

    Type: java.lang.String
    Required: No

Similar Stackoverflow questions:

Customizing Java packages JAXB wsimport

How to generate classes from wsdl using Maven and wsimport?

Upvotes: 1

Related Questions