甜甜大头菜 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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试