<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年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(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 閱讀(1851) | 評論 (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 閱讀(3514) | 評論 (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 閱讀(2110) | 評論 (3)編輯 收藏
    僅列出標題
    共3頁: 上一頁 1 2 3 
    主站蜘蛛池模板: 午夜在线a亚洲v天堂网2019| 亚洲高清中文字幕| 亚洲av无码一区二区三区天堂| 亚洲乱码中文论理电影| 无码日韩精品一区二区免费暖暖 | 亚洲欧洲日韩不卡| 三年在线观看免费观看完整版中文 | 国内大片在线免费看| 男人天堂2018亚洲男人天堂| 中文字幕人成无码免费视频| 免费a级毛片永久免费| 国产亚洲精品美女久久久久久下载| 日本无吗免费一二区| 边摸边吃奶边做爽免费视频网站| 永久免费av无码入口国语片| 亚洲av无码乱码国产精品| 亚洲高清视频在线| 日本无吗免费一二区| 成人免费网站久久久| 亚洲春色在线视频| **一级一级毛片免费观看| www亚洲精品少妇裸乳一区二区| 国产精一品亚洲二区在线播放| 久久青草免费91线频观看不卡| 91亚洲导航深夜福利| 最近中文字幕无吗高清免费视频| 亚洲五月综合缴情在线观看| 免费国产黄网站在线观看视频| 亚洲毛片基地4455ww| 亚洲国产人成中文幕一级二级| 国产一级高青免费| 亚洲中文无码av永久| 免费永久看黄在线观看app| 成全视频免费观看在线看| 亚洲婷婷在线视频| 免费一级特黄特色大片在线| a级毛片免费高清毛片视频| 亚洲av无码国产综合专区| 亚洲美女在线国产| 亚洲w码欧洲s码免费| 91午夜精品亚洲一区二区三区|