Trouble connecting to SOAP service via Java and IntelliJ
<p>I'm having trouble sending off a simple SOAP request and getting a response inside my java project.</p>

<p>I'm still fairly new to doing this via java so I've been looking at <a href="https://spring.io/guides/gs/consuming-web-service/" rel="nofollow">this</a> tutorial since I'm also using spring-boot in the rest of my project.</p>

<p>Currently I'm getting this error (I did have to remove specifics due to being company related and replace with generic strings for the sake of pasting them here. I had to remove my actual wsdl and the actual hostname): </p>

<pre><code>[INFO] --- maven-jaxb2-plugin:0.12.3:generate (default) @ dcc-vm-validation ---
[INFO] Up-to-date check for source resources [[myWsdl, file:pom.xml]] and taret resources [[]].
[WARNING] The URI [myWsdl] seems to represent an absolute HTTP or HTTPS URL. Getting the last modification timestamp is only possible if the URL is accessible and if the server returns the [Last-Modified] header correctly. This method is not reliable and is likely to fail. In this case the last modification timestamp will be assumed to be unknown.
[ERROR] Could not retrieve the last modification timestamp for the URI [myWsdl] from the HTTP URL connection. The [Last-Modified] header was probably not set correctly.
[WARNING] Last modification of the URI [myWsdl] is not known.
[INFO] Sources are not up-to-date, XJC will be executed.
[ERROR] Error while parsing schema(s).Location [].
com.sun.istack.SAXParseException2; IOException thrown when processing "myWsdl". Exception: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching hostname found.
</code></pre>

<p>Here is my "build" section of my pom: </p>

<pre><code>&lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
            &lt;/plugin&gt;

            &lt;plugin&gt;
                &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
                &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
                &lt;version&gt;0.12.3&lt;/version&gt;

                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;generate&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;

                &lt;configuration&gt;
                    &lt;schemaLanguage&gt;WSDL&lt;/schemaLanguage&gt;
                    &lt;generatePackage&gt;package.wsdl&lt;/generatePackage&gt;

                    &lt;schemas&gt;
                        &lt;schema&gt;
                            &lt;url&gt;myWsdl&lt;/url&gt;
                        &lt;/schema&gt;
                    &lt;/schemas&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
</code></pre>

<p>After doing some research on what this specific error means I was able to download the self-signed cert from the wsdl location (via Chrome) to my desktop. I then used keytool to add this specific cert to my cacerts file (I made sure that the cert alias matched the hostname in the error above). As far as I was told, this would fix my connection issues but it didn't. I'm still seeing the same error as above saying that it can't find my  hostname.</p>

<p>What am I missing here?</p>

<p>Alternatively, I also read about bypassing certs altogether. This is also an approach I wouldn't be opposed to since this project I'm working on is ONLY internal and will be located on the company intranet. It won't be accessible by anybody other than employees so the security risks can essentially be ignored. I know this is considered bad practice but I've already read the risks and discussed it with my boss and he's fine if we go this route as well.</p>

<p>I was able to find this little snippet of code that seems to do the job: </p>

<pre><code>static {
            javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
                public boolean verify(String hostname, javax.net.ssl.SSLSession session) {
                    if (hostname.equals(myHostname)) {
                        return  true;
                    }

                    return false;
                }
            });
        }
</code></pre>

<p>but in all the examples I found it never once specified where to put it. It just said that this is what you need to ignore SSL and self-signed cert errors. Where would I put this in correlation to my code and is there a specific way to do this since I'm attempting to do it via spring / jaxb?</p>

<p>Sorry for the long winded wall! Just trying to learn something new over here :)</p>