我正在尝试在我的企业应用程序中编写 JAX-WS 客户端。我的客户端代码如下
...
public class WSClient{
...
MyHelloService service = new MyHelloService();
service.sayHello("Test");
但我得到以下异常
Caused By: java.io.FileNotFoundException: zip:C:/appsrv/domains/xdv_v00_7772_localhost/tmp/_WL_user/geftj9/war/WEB-INF/lib/wsClient.jar!/com/test/MyHelloService.wsdl
我的EAR结构如下
MyEAR.ear
APP-INF/wsdl.jar[contains MyHelloService.wsdl]
APP-INF/stubs.jar[contains stubs of JAX-WS]
somewar.war
WEB-INF/lib/wsdl.jar[contains WSDL]
WEB-INF/lib/stubs.jar[contains stubs of JAX-WS]
WEB-INF/lib/wsClient.jar[This jar has WS Client code using stubs]
我发现 JAX-WS 生成的服务类有以下代码
package com.test;
public class MyHelloService extends Service{
..
MyHelloService(){
..
baseUrl = com.test.MyHelloService.class.getResource(".");
url = new URL(baseUrl, "MyHelloService.wsdl");
..
}
}
我也尝试如下更改我的客户。但它给了我同样的例外。
URL baseUrl = com.test.WSClient.class.getClassLoader().getResource(".");
url = new URL(baseUrl, "MyHelloService.wsdl");
MyHelloService service = new MyHelloService();
service.sayHello("Test");
我想知道如何从 WEB-INF/lib/wsdl.jar 加载 WSDL。任何帮助将不胜感激。