JAVA6 WebService Client Encapsulation

Source: Internet
Author: User

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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.