Prathy Maroor wrote:Generally a web service talks to a remote database to fetch required data. In my case, I have a web service that gets the data from another web application (given the http url). Both are java based applications. How do I communicate with the remote web application ? via HttpUrlConnection? I need to send JSON Objects and receive JSON Arrays. Are there any code examples that I can refer to? Please guide me.
Not sure if you want to just scrape a website (http url part of the question) or if you want to connect to a web service.
To do the first (scrape a website), you can just use the URL class -- which I can confirm works just as well as HttpClient. Or you can use the HttpClient from Apache, which is probably much easier to use, but needs a third party jar. So, the URL class is an option if you don't want another jar in your classpath.
To do the second (connect to a webservice), in the past (many years ago), I used Axis, which works really really well. Since then, Apache has added Axis2, which is supposedly based on a standard. And also, Java 6 has an API built in via JAX-WS. This last option is an option if you don't want another jar in your classpath.
Henry