0

Using Spring Initializer adding only one dependency "Spring Web Service", I created a spring boot maven project as SOAP Web Service Client. I try to use mojohaus/jaxb2-maven-plugin to generate client artifacts from WSDL which is ssl protected. Below is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wsdlUrls>
                        <wsdlUrl>https://sample.com/MyService?WSDL</wsdlUrl>
                    </wsdlUrls>
                    <packageName>com.example.consumingwebservice.wsdl</packageName>
                    <sourceDestDir>src/main/java</sourceDestDir>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I got below error when I run mvn clean package:

parsing WSDL...

[ERROR] PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

After I add

<vmArgs>
    <vmArg>-Djavax.net.ssl.trustStore=path/to/truststore/trust.jks</vmArg>
</vmArgs>

to the configuration section of jaxws-maven-plugin, it seems to me the jaxws-maven-plugin:wsimport finds the truststore but a different error occurs:

parsing WSDL...

[WARNING] schema_reference: Failed to read schema document 'MyService?xsd=1', because 'https' access is not allowed due to restriction set by the accessExternalSchema property.

line 4 of https://sample.com/MyService?WSDL#types?schema1

MyService_schema1.xsd is in the same folder as .wsdl is. It is imported to WSDL.

<definitions xmlns:wsu= ...
<types>
<xsd:schema>
<xsd:import namespace="xxx" schemaLocation="https://sample.com:443/I94WS/I94DocQuery?xsd=1"/>
</xsd:schema>
...

Dose anyone know how to configure the jaxb2-maven-plugin to let its wsimport to access ssl-protected WSDL, or bypass/disable the ssl check?

ITMan
  • 1
  • 1
  • 1
  • 2

0 Answers0