<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 41  文章 - 29  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(5)

    隨筆分類(28)

    隨筆檔案(23)

    收藏夾(6)

    Inside JVM

    Java

    java performance

    Solr

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    The previous message only explains how to create service, this message will describe how to create client and invoke server side. Actually, JSR-311 only defined the server API, so, each vendor will have different ideas on client. But one common way is to use Apache Http Common Client lib. Please see following examples.

    1. GET a customer

    // Sent HTTP GET request to query customer info

    System.out.println(
    "Sent HTTP GET request to query customer info");

    URL url 
    = new URL("http://localhost:8080/vendor_search/services/customerservice/customers/123");

    InputStream in 
    = url.openStream();

    System.out.println(getStringFromInputStream(in)); 
    //NOTE, return an input stream, you need convert xml to Java Object by yourself
    2. Use PUT to update a customer


    System.out.println("Sent HTTP PUT request to update customer info");

    Client client 
    = new Client();

    String inputFile 
    = client.getClass().getResource("update_customer.txt").getFile();

    File input 
    = new File(inputFile);

    PutMethod put 
    = new PutMethod("http://localhost:8080/vendor_search/services/customerservice/customers");

    RequestEntity entity 
    = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");

    put.setRequestEntity(entity);

    HttpClient httpclient 
    = new HttpClient();



    try {

    int result = httpclient.executeMethod(put);

    System.out.println(
    "Response status code: " + result);

    System.out.println(
    "Response body: ");

    System.out.println(put.getResponseBodyAsString());

    finally {

    // Release current connection to the connection pool once you are

    // done

    put.releaseConnection();

    }
    3. Use POST to add a customer

    System.out.println(
    "Sent HTTP POST request to add customer");

    inputFile 
    = client.getClass().getResource("add_customer.txt").getFile();

    input 
    = new File(inputFile);

    PostMethod post 
    = new PostMethod("http://localhost:8080/vendor_search/services/customerservice/customers");

    post.addRequestHeader(
    "Accept" , "text/xml");

    entity 
    = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");

    post.setRequestEntity(entity);

    httpclient 
    = new HttpClient();



    try {

    int result = httpclient.executeMethod(post);

    System.out.println(
    "Response status code: " + result);

    System.out.println(
    "Response body: ");

    System.out.println(post.getResponseBodyAsString());

    finally {

    // Release current connection to the connection pool once you are

    // done

    post.releaseConnection();

    }

    So, for this way provided by Apach Common Http Client, the user still need think about the convention from XML to POJO. It is not so convenience. We will provide a utility class to simply this process.

    posted @ 2008-11-05 22:48 Justin Chen 閱讀(1842) | 評論 (0)編輯 收藏
         摘要: The first article of a series of implementing Restful web service with CXF. This one focus on a very simple service and how to config it in Tomcat container.   閱讀全文
    posted @ 2008-11-05 18:24 Justin Chen 閱讀(3505) | 評論 (1)編輯 收藏
         摘要: This message gives us a brief introduction on Restful web service (All of these information comes from internet and i just re-organized them) and some thoughts on how can we apply this new architecture pattern into our common service services.  閱讀全文
    posted @ 2008-11-05 10:43 Justin Chen 閱讀(2098) | 評論 (3)編輯 收藏
    僅列出標題
    共3頁: 上一頁 1 2 3 
    主站蜘蛛池模板: 免费无码又爽又刺激高潮| 久草免费福利资源站| 四虎成人免费网站在线| 日本一区二区免费看| 亚洲综合国产精品第一页| 黄色免费在线网址| 亚洲第一区精品观看| 亚洲精品一区二区三区四区乱码| a级毛片视频免费观看| 青青草国产免费久久久91| 伊人久久亚洲综合影院首页| 人人揉揉香蕉大免费不卡| 亚洲av无码精品网站| 日韩免费码中文在线观看| 亚洲精品久久久www| 岛国岛国免费V片在线观看| 亚洲阿v天堂在线| 免费无码成人AV在线播放不卡| 亚洲视频在线一区二区三区| 一级大黄美女免费播放| 亚洲欧洲∨国产一区二区三区| 国产偷国产偷亚洲高清在线| 国产国拍亚洲精品福利 | 国产AV无码专区亚洲A∨毛片| 久久免费观看国产精品88av| 亚洲乱码在线视频| 99精品一区二区免费视频| 亚洲国产午夜电影在线入口| 国产成人精品123区免费视频| 国产高清对白在线观看免费91| 亚洲春色在线视频| 在线天堂免费观看.WWW| 新最免费影视大全在线播放| 99亚洲精品高清一二区| 在线观看免费污视频| 久久久免费观成人影院| wwwxxx亚洲| 亚洲日韩精品无码专区网址| 国内精品乱码卡1卡2卡3免费| 猫咪免费观看人成网站在线| 久久亚洲精品成人综合|