The overall idea for improvement is to replace the static part with dynamic, that is, to make the IP and port of the service dynamic, and then flexibly change the configuration parameters based on the deployment of the server.
The following example is an improvement for the client.
1, write the WebService service configuration parameter file
Wscfg.properties
#Java6WS服务的配置
java6ws.wsip=192.168.14.117
java6ws.wsport=8888
2. Write Configuration parameter Acquisition tool
Sysparamstoolkit.java
Package Lavasoft.common
Import java.io.IOException;
import java.util.Properties;
/**
* Media system configuration file parameter Fetch tool
*
* @author leizhimin 2009-11-16 15:21:22
*/
Public final class Sysparamstoolkit {
private static Properties prop;
Private Sysparamstoolkit () {
}
Static {
reload ();
public static Boolean reload () {
Boolean flag = true;
Prop = new Properties ();
try {
Prop.load (SysParamsToolkit.class.getResourceAsStream ("/wscfg.prop Erties "));
flag = false;
} catch (IOException e) {
E.printstacktrace ();
return flag;
}
public static Properties getsysproperties () {
Return prop
}
/**
* Gets the specified system property value
*
* @param key Specifies the property name
* @return The specified system property value
*/
public static string GetProperty (String key) {
return Prop.getproperty (key);
/**
* Gets the property name specified by the specified system property value
*
* @param key
* @param defaultval default Value
* @return specified system property value
*/
public static String ge Tproperty (string key, String defaultval) {
return Prop.getproperty (Key, defaultval);
public static void Main (string[] args) {
Properties prop = Getsysproperties ();
}
}