Java 如何在服务内更改wsdl位置文件
我使用wsimport gradle任务生成了一个初步的MyService,其中提供了wsdl位置路径文件:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdlJava 如何在服务内更改wsdl位置文件,java,wsdl,Java,Wsdl,我使用wsimport gradle任务生成了一个初步的MyService,其中提供了wsdl位置路径文件:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdl public class MyService extends Service { private final static URL MyService_WSDL_LOCATION; private final static Logger logger = Log
public class MyService
extends Service
{
private final static URL MyService_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.google.services.MyService.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.google.services.MyService.class.getResource(".");
url = new URL(baseUrl, "file:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'file:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
MyService_WSDL_LOCATION = url;
}
}
我怎样才能改变它?这是因为文件是在一个环境中生成的,然后工件(war)被移动到另一个服务器
有什么想法吗
是的,我明白了。在当地,一切都很完美。但是这个文件位于war文件中,当Jenkins试图获取这个文件/var/distributives/myservice/tomcat base/wsdl/someLocationWherePlacedMyWSDl.interface.v2.wsdl时,我得到了异常(没有这样的文件或目录)。看起来它无法看到war文件中的文件。有什么想法吗?使用服务类的构造函数
MyService
,传递wsdlLocation
String WSDL_LOCATION = "http://server:port/localtionWSDL.interface.v2.wsdl";
try {
final URL url = new URL(WSDL_LOCATION);
final QName serviceName = new QName("http://mynamespace/", "MyService");
final MyService service = new MyService(url, serviceName);
port = service.getMyServicePort();
// Call some operation of WebService
} catch (final Exception e) {
// Handle the exception
}
我用相对路径解决了这个问题。以下是解决方案
@值(“classpath:com//google//resources//wsdl//myservice.interface.v2.wsdl”)
公共void setWsdlLocation(最终资源wsdlLocation)
{
m_wsdlLocation=wsdlLocation;
}