Notos
甜甜大头菜
采纳率0%
2015-09-01 01:23

@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 CharlesZcswin 2年前

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

    点赞 评论 复制链接分享

相关推荐