2009-08-24

高清無用!

當人人都「講」高清時,我發看很多人其實都將Windows的display解像度set得比native低(可能使用者有老花?),見MSDN Blog Follow-up on High DPI resolution


從圖可見,只有55%的人用native resolution,可悲!

2009-08-06

Quick Building a Web service client using Axis

After some studies, to my surprise, building a web service client using the Axis library (not the web service itself) is in fact very easy. I would like to summarize my experience in this blog.

  1. Download Axis from the Apache web site and expand the zip file (Remark: in fact the whole package includes the server code. To build a client, only the jar files are needed. But for simplicity and because of the limited extra hard disk space, I recommend to expand the whole package).
    In my example, I have downloaded Axis version 1.1 and put it at /home/craft/whc/axis-1-1

  2. Download the WSDL file of the web service. In this case, I have chosen the free stock quote example at webservicex at http://www.webservicex.net/stockquote.asmx?wsdl and store it in /home/craft/whc/StockQuote.wsdl

  3. Use the WSDL2Java tool from Axis to crate the stub codes. Since we need to refer to the jar files in the Axis, I have built a script with classpath set appropriately
    #!/bin/sh
    java -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/wsdl4j.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar"
    org.apache.axis.wsdl.WSDL2Java StockQuote.wsdl
    The resultant files will be created at /home/craft/whc/NET/webserviceX/www

  4. Create the simple client code (StockClient.java) as follows (I have hard-coded MSFT (Microsoft) for the stock code)
    import java.net.URL;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;

    public class StockClient {
    public static void main(String[] args) throws Exception {

    NET.webserviceX.www.StockQuote service = new NET.webserviceX.www.StockQuoteLocator();

    NET.webserviceX.www.StockQuoteSoap port = service.getStockQuoteSoap();
    String result = port.getQuote("MSFT");
    System.out.println("Result = "+result);
    }
    }

  5. Compile the client code with a script as follows (Please note that I have deliberately omitted the wsdl4j.jar because the wsdl file is no longer processed at run time and ass a dot (current directory in the classpath)
    #!/bin/sh
    javac -source 1.5 -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar:." StockClient.java

  6. Run the complied class file (again, I have used a script to add the classpath. Moreover, since we need a http proxy to access the internet, I have defined these properties in during invoking the JVM using the -D switch
    #!/bin/sh
    java -classpath "/home/craft/whc/axis-1_1/lib/axis.jar:
    /home/craft/whc/axis-1_1/lib/log4j-1.2.8.jar:
    /home/craft/whc/axis-1_1/lib/commons-logging.jar:
    /home/craft/whc/axis-1_1/lib/commons-discovery.jar:
    /home/craft/whc/axis-1_1/lib/jaxrpc.jar:
    /home/craft/whc/axis-1_1/lib/saaj.jar:." -Dhttp.proxySet=true -Dhttp.proxyHost="10.36.250.25" -Dhttp.proxyPort=8080 StockClient

    The result is follows:

    [craft:/home/craft/whc (465)] run_client.sh
    Result = <StockQuotes><Stock><Symbol>MSFT</Symbol><Last>23.81</Last><Date>8/5/2009</Date><Time>4:00pm</Time><Change>+0.04</Change><Open>23.93</Open><High>24.25</High><Low>23.79</Low><Volume>53310240</Volume><MktCap>212.2B</MktCap><PreviousClose>23.77</PreviousClose><PercentageChange>+0.17%</PercentageChange><AnnRange>14.87 - 28.50</AnnRange><Earns>1.619</Earns><P-E>14.68</P-E><Name>Microsoft Corpora</Name></Stock></StockQuotes>

2009-08-04

老年十忌

新開幕的時候,曾到過中央圖書館,但發覺很吵鬧,所以也沒有再去了。

近日心血來潮,去打打書釘,發覺環境清淨了很多,真是可喜可賀!

見到國寶季老季羨林的新書《真話能走多遠》,有一篇【老年十忌】,以季老90多年歲寫這題目,特別有份量,同時亦覺得他的開明!

以下其十忌(其實只有九忌)
  1. 說話太多

  2. 倚老賣老(還有一很傳神的翻譯 To take advantage of out's seniority or old age)

  3. 思想僵化

  4. 不服老

  5. 無所事事

  6. 提當年勇

  7. 自我封閉

  8. (不見了)

  9. 老想到死

  10. 憤世嫉俗
希望自己老的時候還記的季老的教誨!