For this web project I need to generate Java classes from some WSDL files (which I have locally in my resources folder) in order to use them in my service. The final aim is to run jar file on web server but the program can't find path to WSDL file while running as a jar.
I am using wsdl2java to generate these classes and the code, where I do that in my build gradle file, looks like the following:
buildscript{
repositories{
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.12'
}
}
plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
apply plugin: 'no.nils.wsdl2java'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
wsdl2java {
wsdlsToGenerate = [
['-p', 'wsdlOne', file("${projectDir}/src/main/resources/wsdl/wsdlOne.wsdl")],
['-p', 'wsdlTwo', file("${projectDir}/src/main/resources/wsdl/wsdlTwo.wsdl")],
['-p', 'wsdlThree', file("${projectDir}/src/main/resources/wsdl/wsdlThree.wsdl")],
['-p', 'wsdlFour', file("${projectDir}/src/main/resources/wsdl/wsdlFour.wsdl")],
['-p', 'wsdlFive', file("${projectDir}/src/main/resources/wsdl/wsdlFive.wsdl")],
]
}
// More lines here...
Project works fine locally, but when I run jar file on the server and test the service which uses WSDL, it crashes with the following exception:
Exception: Failed to access the WSDL at: file:/D:/projects/my_project/src/main/resources/wsdl/wsdlOne.wsdl. It failed with:
/D:/projects/my_project/src/main/resources/wsdl/wsdlOne.wsdl (No such file or directory).
I could replace local addresses of WSDL files with their real http addresses on the web, but I am required to leave them as they are now.
I researched a lot and tried all the possible solutions but I could not find any that would work for my case. I have looked thoroughly (I hope so) through these questions and answers but without results.
If useful in anything, here is the link to see the list of all the optional arguments that can be used to customize code generated from WSDL files by wsdl2Java and you can view the description of wsdl2java gradle plugin here.
I would be very grateful if anyone could give even a slightest hint about what I am missing here.