I'm having trouble sending off a simple SOAP request and getting a response inside my java project.
I'm still fairly new to doing this via java so I've been looking at this tutorial since I'm also using spring-boot in the rest of my project.
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):
[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.
Here is my "build" section of my pom:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>package.wsdl</generatePackage>
<schemas>
<schema>
<url>myWsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>
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.
What am I missing here?
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.
I was able to find this little snippet of code that seems to do the job:
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;
}
});
}
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?
Sorry for the long winded wall! Just trying to learn something new over here :)