锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲精品美女久久久,国产精品久久久久久av福利软件,超碰在线公开http://www.aygfsteel.com/justinchen/category/35770.htmlzh-cnWed, 05 Nov 2008 17:23:24 GMTWed, 05 Nov 2008 17:23:24 GMT60Create Restful Web Service With CXF 2.1.X/CXF 2.2, Part 1: create a service in Tomcat (Contine) - Create client codehttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238909.htmlJustin ChenJustin ChenWed, 05 Nov 2008 14:48:00 GMThttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238909.htmlhttp://www.aygfsteel.com/justinchen/comments/238909.htmlhttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238909.html#Feedback1http://www.aygfsteel.com/justinchen/comments/commentRss/238909.htmlhttp://www.aygfsteel.com/justinchen/services/trackbacks/238909.html

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.



]]>
Create Restful Web Service With CXF 2.1.X/CXF 2.2, Part 1: Create a service in Tomcathttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238868.htmlJustin ChenJustin ChenWed, 05 Nov 2008 10:24:00 GMThttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238868.htmlhttp://www.aygfsteel.com/justinchen/comments/238868.htmlhttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238868.html#Feedback0http://www.aygfsteel.com/justinchen/comments/commentRss/238868.htmlhttp://www.aygfsteel.com/justinchen/services/trackbacks/238868.html闃呰鍏ㄦ枃

]]>
Creating Restful Web Service instead of SOAP web servicehttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238760.htmlJustin ChenJustin ChenWed, 05 Nov 2008 02:43:00 GMThttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238760.htmlhttp://www.aygfsteel.com/justinchen/comments/238760.htmlhttp://www.aygfsteel.com/justinchen/archive/2008/11/05/238760.html#Feedback1http://www.aygfsteel.com/justinchen/comments/commentRss/238760.htmlhttp://www.aygfsteel.com/justinchen/services/trackbacks/238760.html闃呰鍏ㄦ枃

]]>
主站蜘蛛池模板: 上蔡县| 华池县| 旺苍县| 漠河县| 博罗县| 南充市| 长治市| 竹山县| 湟中县| 张家港市| 辉县市| 通城县| 水城县| 阿鲁科尔沁旗| 兴海县| 册亨县| 东海县| 张掖市| 双江| 崇信县| 江陵县| 黄梅县| 朝阳县| 巩留县| 新源县| 阳谷县| 隆尧县| 忻城县| 兴和县| 方城县| 萨迦县| 建始县| 奎屯市| 巴林左旗| 古蔺县| 高清| 义乌市| 嘉鱼县| 泗水县| 两当县| 会理县|