我有一个 SOAP Web 服务,是使用 wsimport
从 .wsdl
中提取的
现在,当打开生成的文件时,我需要删除 file://
引用。
我将 WSDL 移至 src/main/resources/Services/RecherchePoint-v2.0.wsdl
但是现在,我有几个引用资料不知道如何更新:
@WebServiceClient(name = "RecherchePointV2.0", targetNamespace = "http://www.enedis.fr/sge/b2b/services", wsdlLocation = "file:/home/ubuntu/wsdl/Services/RecherchePoint/RecherchePoint-v2.0.wsdl")
...
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("file:/home/ubuntu/wsdl/Services/RecherchePoint/RecherchePoint-v2.0.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
RECHERCHEPOINTV20_WSDL_LOCATION = url;
RECHERCHEPOINTV20_EXCEPTION = e;
}
我尝试改变:
file:/home/ubuntu/wsdl/Services/RecherchePoint/RecherchePoint-v2.0.wsdl"
到
../../../resources/wsdl/Services/RecherchePoint/RecherchePoint-v2.0.wsdl"
但它不起作用。
知道如何改变它吗?
最佳答案
您可以使用org.springframework.core.io.ClassPathResource
/**
* {@link Resource} implementation for class path resources. Uses either a
* given {@link ClassLoader} or a given {@link Class} for loading resources.
*
* <p>Supports resolution as {@code java.io.File} if the class path
* resource resides in the file system, but not for resources in a JAR.
* Always supports resolution as URL.
*
*/
new ClassPathResource("Services/RecherchePoint-v2.0.wsdl")
Here一些解释。
关于java - 如何引用 src/main/resources 文件夹中的 .wsdl 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58545745/