Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

HTTP-RPC 4.0 Released

DZone's Guide to

HTTP-RPC 4.0 Released

HTTP-RPC is the cornerstone of many a web-based Java application. Come check out what's new with the latest major release, HTTP-RPC 4.0 and see where you can get your hands on it.

· Web Dev Zone
Free Resource

Tips, tricks and tools for creating your own data-driven app, brought to you in partnership with Qlik.

HTTP-RPC 4.0 is now available for download. This release adds support for application/x-www-form-urlencoded and application/json request encodings. In addition to submitting request arguments as multipart/form-data, client applications can now POST arguments as URL-encoded key/value pairs and POST or PUT argument values as JSON.

For example, the following Java code would submit a JSON-encoded POST request to the resource located at /example:

serviceProxy.setEncoding(WebServiceProxy.APPLICATION_JSON);

serviceProxy.invoke("POST", "/example", mapOf(
    entry("string", "hello"),
    entry("number", 123),
    entry("flag", true)), (result, exception) -> {
    // ...
});


In Swift, the code might look like this:

serviceProxy.encoding = WSApplicationJSON

serviceProxy.invoke("POST", path: "/example", arguments: [
    "string": "hello",
    "number": 123,
    "flag": true
    ]) { result, error in
    // ...
}


In either case, the body of the request would contain the following:

{
  "string": "hello",
  "number": 123,
  "flag": true
}


For more information, see the project README.

Explore data-driven apps with less coding and query writing, brought to you in partnership with Qlik.

Topics:
release ,project ,http-rpc ,major ,java

Published at DZone with permission of Greg Brown, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}