java - JAR 中资源的 URL

标签 java url wsdl

我需要获取 jar 文件中资源的 URL。我使用此 URL 作为服务调用的参数。我的下面的代码失败并出现“没有这样的文件或目录”错误。

File file = new File(classLoader.getResource("AXLAPI.wsdl").getFile());
final URL wsdlURL = new URL(this.getClass().getResource(this.getClass().getSimpleName() +".class"),file.toString());
String endpoint = "https://<machine>:8443/axl/";
AXLAPIService ss = new AXLAPIService( wsdlURL );

下面是执行此操作时看到的错误 -

Failed to access the WSDL at: file:/blah/blah/blah.jar!/AXLAPI.wsdl. It failed with: 
/blah/blah/blah.jar!/AXLAPI.wsdl (No such file or directory).

我真的很感激任何处理这个问题的建议!

最佳答案

我认为正确的网址应该是

jar:file:/blah/blah/blah.jar!/AXLAPI.wsdl

关于java - JAR 中资源的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11250011/

相关文章:

ios - 向后播放视频

java - Tomcat 重新启动或重新部署会破坏 java 源文件中的 unicode 字符

java - 使用 shell 文件运行 jar 并指定类路径和属性文件路径

Java 不识别 ArrayList 中的元素?

java - 如何从 OSGi 组件中的第三方 jar 文件导入类

url - 如何获取或拥有自己的 IP 地址?

java - 如何用 JSON 表示数据库中的图像

java - 避免使用 web.xml 硬编码 WSDL 位置

WCF 托管、配置和连接地址/端口问题(包括 Delphi 7 客户端)

JAVA:经过这么多时间后中断线程