@WebServiceClient(name = "smsInterface", targetNamespace = "http://ws.sms.surge.com", wsdlLocation = "http://192.168.101.215:8080//ws/smsInterface?wsdl")public class SmsInterface
extends Service
{xxxxxxx}
这是解析wsdl出来的某个方法,这里注解中的wsdllocation的ip地址和端口是确定的,如果我要在配置文件中修改这个ip和端口号,让他们变成动态的,要怎么做?我了解到注解中的内容应该是不能动态变动的,但我的ip和端口会变化的话就无法拿到wsdl文件了,请问怎么实现?我写了如下代码在方法中,不知道是否可以实现上述要求,这样会和wsdllocation中的地址冲突吗?
//从properties文件中获得ip的地址
static String wsdlip = TianHongConfig.getThirdIP();
//从properties文件中获得端口的地址
static String wsdlport = TianHongConfig.getThirdPort();
static String wsdlurl = "http://"+wsdlip+":"+wsdlport+"/ws/smsInterface?wsdl";
private final static URL SMSINTERFACE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.surge.sms.ws.SmsInterface.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.surge.sms.ws.SmsInterface.class.getResource(".");
/*url = new URL(baseUrl, "http://192.168.101.215:8080/ws/smsInterface?wsdl");*/
url = new URL(baseUrl, wsdlurl);
} catch (MalformedURLException e) {
/*logger.warning("Failed to create URL for the wsdl Location: 'http://192.168.101.215:8080/ws/smsInterface?wsdl', retrying as a local file");*/
logger.warning("Failed to create URL for the wsdl Location: "+wsdlurl+", retrying as a local file");
logger.warning(e.getMessage());
}
SMSINTERFACE_WSDL_LOCATION = url;