2
我正在使用Apache CXF連接到SOAP API。我在我的Eclipse項目中保存了WSDL,我想加載它。我的項目是這樣的:Java - Apache CXF從Jar加載WSDL
src
gen
resources +
META-INF +
myWSDL.wsdl
我可以加載WSDL,如果我從我的驅動器的根目錄的路徑硬代碼:
static {
URL url = null;
try {
url = new URL("file:/home/peter/workspace/project/resources/META-INF/myWSDL.wsdl");
System.out.println(url);
} catch (MalformedURLException e) {
//blah
}
}
但是,如果我嘗試加載WSDL作爲它失敗的資源:
static {
URL url = null;
try {
url = MyServiceClass.class.getResource("/resource/META-INF/BFExchangeService.wsdl");
System.out.println(url); //prints null
} catch (MalformedURLException e) {
//blah
}
}
如何從我的項目(並最終,我的.jar)中加載WSDL?
乾杯,
皮特