In Java, I'm using the wsimport tool. The process works. However there are some problems.
I have to do the wsimport in the services of several different providers (all of them third, I have no control over them). WSDLs are almost identical, just changing the destination URL.
Each of these WSDLs defines a lot of different operations / methods. It happens that among this lot of operations, only a 2 or 3 I'm really going to need. Almost at the end of each of these WSDLs there is this:
<wsdl:service name="Exemplo">
<wsdl:port name="ExemploSoap" binding="tns:ExemploSoap">
<soap:address location="https://www.example.com/wsIntegracao/exemplo.asmx" />
</wsdl:port>
<wsdl:port name="ExemploSoap12" binding="tns:ExemploSoap12">
<soap12:address location="https://www.example.com/wsIntegracao/exemplo.asmx" />
</wsdl:port>
</wsdl:service>
From one WSDL to another, almost nothing changes. In general, the only thing that changes are those URLs that are in the excerpt above.
Here's the relevant part of pom.xml
. I have this for each different WSDL / service, so each of them will generate a distinct JAR (there is a pom.xml
for each service, each in a different folder).
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>servico-teste.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>servico-teste.wsdl</wsdlLocation>
<wsdlDirectory>${basedir}</wsdlDirectory>
<packageName>br.com.example.servico2</packageName>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-Xlint:none</arg>
</compilerArgs>
</configuration>
</plugin>
The differences between pom.xml
and other are minimal. Just about the name of the package to be generated and the name of the WSDL file.
As I mentioned, the process works. But this way, if I have 20 different services, 20 almost identical JAR files will be generated. If each of them has 100 classes, this will generate 2000 different classes in 20 JARs, and only 3 or 4 I use effectively.
So I ask two questions:
Is there any way to optimize wsimport so that it needs to be run only once when the services are the same or similar enough, where only the URL in soap:address location
varies? >
Is there any way to instruct wsimport to generate only the classes needed for a particular part of the WSDL, not everything that is referenced in the WSDL?