Describes a Java open-source project Resty that allows you to conveniently call RESTful services.

Source: Internet
Author: User

You can find the Resty Project address in git.

Resty supports text, XML, JSON, and binary. It is very convenient to use and has detailed instructions on the official website.

In order to give you a perceptual knowledge, we will provide an XML instance and solve the Chinese Garbled text problem:

        Resty r = new Resty();
NodeList nl=r.xml("http://218.22.67.142:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=wuhu:shuili_hanzhadoumen&maxFeatures=5").get("FeatureCollection/featureMember/shuili_hanzhadoumen/name");
for (int i = 0, len = nl.getLength(); i < len; i++) {
Node node=(Node)nl.item(i);
System.out.println(new String(node.getTextContent().getBytes("ISO-8859-1"),"GBK"));
}

Output result:

Dual ferry gate
Plow head (gate)
Wangcun Station Gate
Boshun Station Gate

 

XML code:

<Wfs: FeatureCollection xmlns = "http://www.opengis.net/wfs" xmlns: wfs = "http://www.opengis.net/wfs" xmlns: wuhu = "www.wuhu.cn" xmlns: gml = "http://www.opengis.net/gml" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "www.wuhu.cn http: // 218.22.67.142: 8080/geoserver/wfs? Service = WFS & version = 1.0.0 & request = DescribeFeatureType & typeName = wuhu % parse http://www.opengis.net/wfs http: // 218.22.67.142: 8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd ">
<Gml: boundedBy>
<Gml: null> unknown </gml: null>
</Gml: boundedBy>
<Gml: featureMember>
<Wuhu: shuili_hanzhadoumen fid = "shuili_hanzhadoumen.1">
<Wuhu: the_geom>
<Gml: Point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326">
<Gml: coordinates xmlns: gml = "http://www.opengis.net/gml" decimal = "." cs = "," ts = ""> 118.347698, 31.358407 </gml: coordinates>
</Gml: Point>
</Wuhu: the_geom>
<Wuhu: LAYER> Unknown Point Feature </wuhu: LAYER>
<Wuhu: id> 0 </wuhu: id>
<Wuhu: name/>
<Wuhu: type> 0 </wuhu: type>
<Wuhu: flag> 0 </wuhu: flag>
</Wuhu: shuili_hanzhadoumen>
</Gml: featureMember>
<Gml: featureMember>
<Wuhu: shuili_hanzhadoumen fid = "shuili_hanzhadoumen.2">
<Wuhu: the_geom>
<Gml: Point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326">
<Gml: coordinates xmlns: gml = "http://www.opengis.net/gml" decimal = "." cs = "," ts = ""> 118.416961, 31.546034 </gml: coordinates>
</Gml: Point>
</Wuhu: the_geom>
<Wuhu: LAYER> Unknown Point Feature </wuhu: LAYER>
<Wuhu: id> 0 </wuhu: id>
<Wuhu: name> dual-ferry gate </wuhu: name>
<Wuhu: type> 0 </wuhu: type>
<Wuhu: flag> 0 </wuhu: flag>
</Wuhu: shuili_hanzhadoumen>
</Gml: featureMember>
<Gml: featureMember>
<Wuhu: shuili_hanzhadoumen fid = "shuili_hanzhadoumen.3">
<Wuhu: the_geom>
<Gml: Point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326">
<Gml: coordinates xmlns: gml = "http://www.opengis.net/gml" decimal = "." cs = "," ts = ""> 118.381909, 31.510878 </gml: coordinates>
</Gml: Point>
</Wuhu: the_geom>
<Wuhu: LAYER> Unknown Point Feature </wuhu: LAYER>
<Wuhu: id> 0 </wuhu: id>
<Wuhu: name> plow head point station (gate) </wuhu: name>
<Wuhu: type> 0 </wuhu: type>
<Wuhu: flag> 0 </wuhu: flag>
</Wuhu: shuili_hanzhadoumen>
</Gml: featureMember>
<Gml: featureMember>
<Wuhu: shuili_hanzhadoumen fid = "shuili_hanzhadoumen.4">
<Wuhu: the_geom>
<Gml: Point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326">
<Gml: coordinates xmlns: gml = "http://www.opengis.net/gml" decimal = "." cs = "," ts = ""> 118.39178, 31.499681 </gml: coordinates>
</Gml: Point>
</Wuhu: the_geom>
<Wuhu: LAYER> Unknown Point Feature </wuhu: LAYER>
<Wuhu: id> 0 </wuhu: id>
<Wuhu: name> Wangcun Station Gate </wuhu: name>
<Wuhu: type> 0 </wuhu: type>
<Wuhu: flag> 0 </wuhu: flag>
</Wuhu: shuili_hanzhadoumen>
</Gml: featureMember>
<Gml: featureMember>
<Wuhu: shuili_hanzhadoumen fid = "shuili_hanzhadoumen.5">
<Wuhu: the_geom>
<Gml: Point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326">
<Gml: coordinates xmlns: gml = "http://www.opengis.net/gml" decimal = "." cs = "," ts = ""> 118.400652, 31.499075 </gml: coordinates>
</Gml: Point>
</Wuhu: the_geom>
<Wuhu: LAYER> Unknown Point Feature </wuhu: LAYER>
<Wuhu: id> 0 </wuhu: id>
<Wuhu: name> boshun gate </wuhu: name>
<Wuhu: type> 0 </wuhu: type>
<Wuhu: flag> 0 </wuhu: flag>
</Wuhu: shuili_hanzhadoumen>
</Gml: featureMember>
</Wfs: FeatureCollection>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.