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 Details

  • Constructor Details

    • RestClient

      public RestClient()
    • RestClient

      public RestClient(String rootURL)
  • Method Details

    • 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 URI
      dataString - - content
      contentType - - 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 URI
      dataString - - content
      contentType - - request MediaType
      acceptType - - 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 URI
      data - - content
      contentType - - request MediaType
      acceptType - - 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 URI
      data - - content
      contentType - - request MediaType
      acceptType - - 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