Package org.imixs.workflow.services.rest
Class RestClient
- java.lang.Object
-
- org.imixs.workflow.services.rest.RestClient
-
public class RestClient extends Object
The Imixs RestClient is a helper class for a Rest based communication without the use of Jax-rs.The Imixs RestClient provides methods to GET and POST data objects.
The client throws a RestAPIException in case of an communication error.
For a convinient way to access the Imixs-Rest API use the Imixs-Melman project on Github.
- Author:
- Ralph Soika
-
-
Field Summary
Fields Modifier and Type Field Description protected List<RequestFilter>
requestFilterList
-
Constructor Summary
Constructors Constructor Description RestClient()
RestClient(String rootURL)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
get(String uri)
Gets the content of a GET request from a Rest Service URI Endpoint.String
getEncoding()
int
getLastHTTPResult()
This method returns the last HTTP ResultString
getServiceEndpoint()
String
post(String uri, byte[] data, String _contentType)
Posts a byte array to a Rest Service URI Endpoint.String
post(String uri, byte[] data, String _contentType, String acceptType)
Posts a byte array to a Rest Service URI Endpoint.String
post(String uri, String dataString, String contentType)
Posts a String data object with a specific Content-Type to a Rest Service URI Endpoint.String
post(String uri, String dataString, String _contentType, String acceptType)
Posts a String data object with a specific Content-Type to a Rest Service URI Endpoint.void
registerRequestFilter(RequestFilter filter)
Register a ClientRequestFilter instance.void
setEncoding(String aEncoding)
void
setRequestProperty(String key, String value)
Set a single header request property
-
-
-
Field Detail
-
requestFilterList
protected List<RequestFilter> requestFilterList
-
-
Constructor Detail
-
RestClient
public RestClient()
-
RestClient
public RestClient(String rootURL)
-
-
Method Detail
-
registerRequestFilter
public void registerRequestFilter(RequestFilter filter)
Register a ClientRequestFilter instance.- Parameters:
filter
- - request filter instance.
-
getEncoding
public String getEncoding()
-
setEncoding
public void setEncoding(String aEncoding)
-
getServiceEndpoint
public String getServiceEndpoint()
-
setRequestProperty
public void setRequestProperty(String key, String value)
Set a single header request property
-
post
public String post(String uri, String dataString, String contentType) throws RestAPIException
Posts a String data object with a specific Content-Type to a Rest Service URI Endpoint. This method can be used to simulate different post scenarios.The parameter 'contnetType' can be used to request a specific media type.
- Parameters:
uri
- - Rest Endpoint URIdataString
- - contentcontentType
- - request MediaType- Returns:
- content
- Throws:
RestAPIException
Exception
-
post
public String post(String uri, String dataString, String _contentType, String acceptType) throws RestAPIException
Posts a String data object with a specific Content-Type to a Rest Service URI Endpoint. This method can be used to simulate different post scenarios.The parameter 'contnetType' and 'acceptType' can be used to request and accept specific media types.
- Parameters:
uri
- - Rest Endpoint URIdataString
- - contentcontentType
- - request MediaTypeacceptType
- - accept MediaType- Returns:
- content
- Throws:
RestAPIException
-
post
public String post(String uri, byte[] data, String _contentType) throws RestAPIException
Posts a byte array to a Rest Service URI Endpoint. This method can be used to simulate different post scenarios.The parameter 'contnetType' and 'acceptType' can be used to request and accept specific media types.
- Parameters:
uri
- - Rest Endpoint URIdata
- - contentcontentType
- - request MediaTypeacceptType
- - accept MediaType- Returns:
- content
- Throws:
RestAPIException
-
post
public String post(String uri, byte[] data, String _contentType, String acceptType) throws RestAPIException
Posts a byte array to a Rest Service URI Endpoint. This method can be used to simulate different post scenarios.The parameter 'contnetType' and 'acceptType' can be used to request and accept specific media types.
- Parameters:
uri
- - Rest Endpoint URIdata
- - contentcontentType
- - request MediaTypeacceptType
- - accept MediaType- Returns:
- content
- Throws:
RestAPIException
-
getLastHTTPResult
public int getLastHTTPResult()
This method returns the last HTTP Result- Returns:
-
get
public String get(String uri) throws RestAPIException
Gets the content of a GET request from a Rest Service URI Endpoint. I case of an error the method throws a RestAPIException.- Parameters:
uri
- - Rest Endpoint RUI- Returns:
- - content or null if no content is available.
- Throws:
RestAPIException
-
-