甜甜大头菜 2015-09-01 01:23 采纳率: 0%
浏览 11933

@WebServiceClient注解的loation中的ip地址可以动态改变吗?

@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;
  • 写回答

1条回答 默认 最新

  • CharlesZcswin 2019-01-22 10:35
    关注

    可以,会有查阅文档的故障冲突,但不影响客户端服务运行

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料