banner
RustyNail

RustyNail

coder. 【blog】https://rustynail.me 【nostr】wss://ts.relays.world/ wss://relays.world/nostr

Integrating SOAP (WSDL) Calls in Spring Boot

To work, data interaction with .net platform services is required, and the platform provides a WSDL. However, the system I am working on is developed using the Java stack.

General process:

  • Obtain the WSDL link, such as http://xxx.xxx.xxx.xxx:xxxx/ooooo/xxxxx.svc?wsdl
  • Use the wsimport.exe under JDK_HOME/bin to generate the calling code, or use the plugin in idea to generate the Stub class.
  • Directly call the methods using the newly generated class.

Using wsimport#

wsimport is located in JDK_HOME/bin, execute it directly.

wsimport -s /target_directory http://xxxxx.svc/wsdl

Then, put the generated Java classes into the project.

The WSDL XML has a wsdl:service tag with a name attribute. Create an instance of that class to call its methods.

Using idea plugin#

Idea has built-in code generation functionality. Select a package and in the title bar, choose tool->webservice->gen java code from wsdl.

After generation, the files may be placed in the wrong location. Adjust the package name and folder accordingly.

Add the following dependencies to the pom file (adjust the version as needed):

 <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2 -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.7.9</version>
            <type>pom</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-adb -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.7.9</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-transport-local -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.7.9</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-transport-http -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.7.9</version>
        </dependency>

Otherwise, the application may not start or may throw errors such as:

2021-06-21 15:00:08.786 [http-nio-23333-exec-1] ERROR c.g.xxxxx.filter.JwtFilter - org.apache.axis2.transport.http.CommonsHTTPTransportSender
org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
	at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:736)
	at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:123)
	at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:629)
	at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
	at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
	at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.