how to generate WSDL stubs with Jakarta using Maven

376 views Asked by At

I need to generate java files from .wsdl file with jakarta. I'm using java 20

I used jakarta dependency and below plugin and run mvn clean install

Here is a part of my .wsdl file

---

<wsdl:binding name="HexingWsServiceSoapBinding" type="tns:HexingWs">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="trans">
      <soap:operation soapAction="" style="rpc"/>
      <wsdl:input name="trans">
        <soap:body namespace="http://service.ws.tangdi/" use="literal"/>
      </wsdl:input>
      <wsdl:output name="transResponse">
        <soap:body namespace="http://service.ws.tangdi/" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="HexingWsService">
    <wsdl:port binding="tns:HexingWsServiceSoapBinding" name="HexingWsPort">
      <soap:address location="http://-------------------------"/>
    </wsdl:port>
  </wsdl:service>
<dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <version>4.0.1</version>
        </dependency>
<plugin>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>4.0.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wsdlDirectory>Development/middle-ware/utility/src/main/resources/</wsdlDirectory>
                    <wsdlFiles>
                        <wsdlFile>hexingws.wsdl</wsdlFile>
                    </wsdlFiles>
                    <packageName>com.omo.robi.ThirdpartyRequest.webservice</packageName>
                    <sourceDestDir>
                        Development/middle-ware/utility/src/main/java/
                    </sourceDestDir>
                </configuration>
            </plugin>

java files are not creating with this method. I have a confusion in putting <sourceDestDir> and <packageName> attributes

I would like to know what is the mistake I have done here and are there any other methods to do this.

Is there a way to do this using Apache Axis

since I'm a newbie if someone can explain this step by step, it will be so helpful to me

1

There are 1 answers

0
Hashini Udara On

Below documentation and few modifications in pom.xml solved the issue.

Added jakarta dependencies in pom.

Added following plugin in pom.

<plugin>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>4.0.1</version>
<executions>
    <execution>
        <goals>
            <goal>wsimport</goal>
        </goals>
    </execution>
</executions>
<configuration>
    <wsdlDirectory>${project.basedir}/src/main/resources/</wsdlDirectory>
    <packageName>com.baeldung.soap.ws.client</packageName>
    <sourceDestDir>
        ${project.build.directory}/generated-sources/
    </sourceDestDir>
</configuration>

Change the values of

packageName

and

wsdlDirectory

properties according to your project.

Then run

mvn clean install

The generated classes can be found in the place as configured in the

packageName

property.

Use the compatible versions for your project.

Here I put the link to the document for further studying.

link to document

hope this will help someone :)