public class CommandableHttpClient extends RestClient
Commandable services are generated automatically for ICommandable objects. Each command is exposed as POST operation that receives all parameters in body object.
### Configuration parameters ###
### References ###
### Example ###
class MyCommandableHttpClient extends CommandableHttpClient implements IMyClient {
...
public MyData getData(String correlationId, String id) {
return this.callCommand(
MyData.class,
"get_data",
correlationId,
new MyData(id)
);
}
...
}
MyCommandableHttpClient client = new MyCommandableHttpClient();
client.configure(ConfigParams.fromTuples(
"connection.protocol", "http",
"connection.host", "localhost",
"connection.port", 8080
));
MyData data = client.getData("123", "1");
...
_baseRoute, _client, _connectionResolver, _counters, _logger, _options, _retries, _url| Constructor and Description |
|---|
CommandableHttpClient(String baseRoute)
Creates a new instance of the client.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
callCommand(Class<T> type,
String route,
String correlationId,
Object entity)
Calls a remote method via HTTP commadable protocol.
|
<T> T |
callCommand(javax.ws.rs.core.GenericType<T> type,
String route,
String correlationId,
Object entity)
Calls a remote method via HTTP commadable protocol.
|
addCorrelationId, addFilterParams, addPagingParams, close, configure, execute, execute, executeRequest, instrument, isOpen, open, setReferencespublic CommandableHttpClient(String baseRoute)
baseRoute - a base route for remote service.public <T> T callCommand(Class<T> type, String route, String correlationId, Object entity) throws org.pipservices.commons.errors.ApplicationException
type - the class type.route - a name of the command to call.correlationId - (optional) transaction id to trace execution through
call chain.entity - body object.org.pipservices.commons.errors.ApplicationException - when error occured.public <T> T callCommand(javax.ws.rs.core.GenericType<T> type,
String route,
String correlationId,
Object entity)
throws org.pipservices.commons.errors.ApplicationException
type - the generic class type.route - a name of the command to call.correlationId - (optional) transaction id to trace execution through
call chain.entity - body object.org.pipservices.commons.errors.ApplicationException - when error occured.Copyright © 2018. All rights reserved.