wsdl_ip.properties:
person=http://localhost:8080/CXF_3/cxf/person?wsdl
---------------------------------------------------------------------
IpPortUtils.java
package cn.itcast.cxf.service.utils;
import java.io.InputStream;
import java.util.Properties;
import org.apache.cxf.common.util.StringUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
public class IpPortUtils {
public static String getIpPort(String key) {
try {
Resource resource = new ClassPathResource("cn/itcast/cxf/service/wsdl_ip.properties");
InputStream inputStream = resource.getInputStream();
Properties p = new Properties();
p.load(inputStream);
String ip = p.getProperty(key);
System.out.println("get WSDL("+key+") ip:[" + ip +"]");
return StringUtils.isEmpty(ip) ? "http://localhost:80" : ip;
} catch (Exception e) {
e.printStackTrace();
return "http://localhost:80";
}
}
}
本文介绍了一个用于从属性文件中读取WSDL URL的Java实用工具类。该类使用Spring框架来定位属性文件的位置,并提供了获取特定键对应的值的方法。如果属性文件中未找到指定的键,则返回默认的本地主机地址。
7250

被折叠的 条评论
为什么被折叠?



