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.
Join the DZone community and get the full member experience.
Join For FreeHTTP-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.
Published at DZone with permission of Greg Brown, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments