0

After trying to understand how wsdl2java plugin works, I got to understand that in the configuration in pom, we specify the package name where the skeletons will be generated from the wsdl.

<goals>
   <goal>wsdl2code</goal>
</goals>
<configuration>
    <packageName>com.a.b.c.d</packageName>
    <wsdlFile>${project.build.directory}/../src/main/webapp/WEB-INF/c/d/META-INF/wsdlfile.wsdl</wsdlFile>
</configuration>

As for the classes, the WSDL file imports the xsd namespace, and the classes are generated in two package s that takes the namespace as a name. the first is namespace/publics, the second namespace/types

<wsdl:definitions xmlns:ns="http://a.b.c.d.com" xmlns:ns3="http://a.b.c.d.com/types" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://a.b.c.d.com">
<wsdl:types>
    <xs:schema xmlns:stn_51="http://a.b.c.d.com/publics" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:types="http://a.b.c.d.com/types" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://a.b.c.d.com/types">
        <xs:import namespace="http://a.b.c.d.com/publics" schemaLocation="xsd0.xsd" />

The problem is the package name which is identical to a package name in another module which leads to confusion. Is there an option in wsdl2java to solve this? Or is there a way to solve this using the wsdl?

1 Answers1

1

So I got to solve this by looking at the documentation of wsdl2code where I've found about this tag: NamespaceURLs. It allows you to specify a list of namespaces, and each one of them a specific package name. here is an example of how to use it in POM.

<execution>
                    <id>...</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                    <namespaceURIs>
                      <namespaceURI>
                        <uri>http://a.b.c.d.com/publics</uri>
                        <packageName>com.d.c.b.a.service-a.publics</packageName>
                      </namespaceURI>

                    </namespaceURIs>
                        <packageName>com.d.c.b.a.service-a</packageName>
                        <wsdlFile>...</wsdlFile>
                    </configuration>
                </execution>