<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 
    主站蜘蛛池模板: 国产亚洲精品美女| 污污视频免费观看网站| 91成人免费观看| 亚洲精品美女在线观看播放| 最近中文字幕大全中文字幕免费 | 日本高清高色视频免费| 亚洲AV无码国产精品麻豆天美| a级成人毛片免费视频高清| 久久久久亚洲AV无码专区首| 日本免费污片中国特一级| 亚洲欧洲日韩综合| 无码一区二区三区免费视频 | 无遮挡免费一区二区三区| 亚洲成AV人网址| 久久久免费观成人影院| 亚洲av无码不卡| 丁香花免费完整高清观看| 亚洲欧美国产日韩av野草社区| 国产男女猛烈无遮挡免费视频| 野花视频在线官网免费1| 亚洲三区在线观看无套内射| 无码人妻一区二区三区免费看| 亚洲日本视频在线观看| 午夜免费不卡毛片完整版| 一级毛片在播放免费| 亚洲人成电影福利在线播放| 久久精品网站免费观看| 杨幂最新免费特级毛片| 亚洲国产精品成人久久| 一本无码人妻在中文字幕免费| 香蕉视频免费在线播放| 亚洲国产成人久久精品动漫| 国产香蕉九九久久精品免费| 尤物视频在线免费观看| 亚洲免费网站在线观看| 亚洲国产一成久久精品国产成人综合| 男女作爱在线播放免费网站| 亚洲色大成网站www尤物| 中文字幕亚洲无线码| 黄瓜视频影院在线观看免费| 一级一级一片免费高清|