开发者

Web service call client code

开发者 https://www.devze.com 2023-02-02 06:18 出处:网络
HI, I want to call a web service from java standalone client. The constraint that is imposed that I have not to make an object of interface (of webservice to ba 开发者_如何学Ccalled). This code should

HI, I want to call a web service from java standalone client. The constraint that is imposed that I have not to make an object of interface (of webservice to ba 开发者_如何学Ccalled). This code should pass few parameters and in return gets a boolean value. Can anyone have an idea?


Take a look at the Restlet project. It's a framework that can run as either a web application or as a standalone client. It's a framework designed for building REST servers and clients:

http://www.restlet.org/


If you want a client only version and you are talking to XML, JSON or plain text, nothing beats Resty regarding lines of code and dependencies.

Here is an example getting JSON from Geonames.org and navigating to the first placeName result:

Resty r = new Resty();
Object name = r.json("http://ws.geonames.org/postalCodeLookupJSON?postalcode=66780&country=DE").
    get("postalcodes[0].placeName");

Resty supports cookies and authentication and goes out of your way otherwise. If you want the InputStream to read the data yourself, feel free to do so.

http://beders.github.com/Resty/

0

精彩评论

暂无评论...
验证码 换一张
取 消