-1

My app is supposed to call a URL which would provide simple text data (1 or 0). The URL can be http/https and method is POST.

For example, my java app will call https://web.address.com:1234/isActive with some request parameter and then this URL would simply return 0 or 1 in text format.

What lightweight API should I use? Or can I use Play Framework's WS API only (not the whole framework)?

Khalid Saifullah
  • 737
  • 2
  • 8
  • 21

1 Answers1

1

For this "simple" task you can use Java's URL and URLConnection classes from the standard library which are capable of connecting to a remote server and perform basic HTTP operations. Also know that URL.openConnection() returns an HttpURLConnection instance with many helper/utility methods and constants regarding HTTP protocol.

Also see this excellent post which provides you more details and examples including performing an HTTP POST operation:

Using java.net.URLConnection to fire and handle HTTP requests

If you don't want to "do-it-yourself", there are numerous 3rd party libraries availabe (google it). To mention a few:

Apache HttpComponents (former Apache HttpClient)

Google HTTP Client Library

Community
  • 1
  • 1
icza
  • 289,344
  • 42
  • 658
  • 630