public interface RestServiceAdapter
| Modifier and Type | Field and Description | 
|---|---|
| static String | REQUEST_TYPE_DELETE | 
| static String | REQUEST_TYPE_GET | 
| static String | REQUEST_TYPE_POST | 
| static String | REQUEST_TYPE_PUT | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addRequestProperty(String key,
                  String value)Add request property to the request header. | 
| void | clearRequestProperties()Clear all previously set request properties. | 
| void | close(javax.microedition.io.HttpConnection connection)Close the provided connection. | 
| String | getConnectionEndPoint(String connName)Return the end point of the connection, for the specified connection name,
 found in connections.xml. | 
| String | getConnectionName()Set the connection name (referenced in connections.xml) that REST requests
 should be directed to. | 
| javax.microedition.io.HttpConnection | getHttpConnection(String requestMethod,
                 String request,
                 Object httpHeadersValue)Initializes and returns an HttpConnection, using the provided request
 method, request, and HTTP headers value. | 
| String | getHttpStatusMessage(int httpStatusCode) | 
| java.io.InputStream | getInputStream(javax.microedition.io.HttpConnection connection)Open and return an input stream for the provided connection. | 
| java.io.OutputStream | getOutputStream(javax.microedition.io.HttpConnection connection)Open and return an output stream for the provided connection. | 
| String | getRequestMethod() | 
| java.util.Map<String,String> | getRequestProperties() | 
| String | getRequestURI() | 
| String | getResponseContentType()Retrieve the content type of the response | 
| String | getResponseHeader(String key)Retrieve response header. | 
| java.util.Map<String,String> | getResponseHeaders() | 
| String | getResponseMessage() | 
| int | getResponseStatus() | 
| int | getRetryLimit() | 
| boolean | isGenerateAnalyticsEvents() | 
| void | removeRequestProperty(String key)Remove a request property from the request header. | 
| String | send(String payload)Send the REST request with the given payload | 
| byte[] | sendReceive(String payload)Send the REST request with the given payload | 
| java.io.InputStream | sendRequest(String payload)Send a REST request with the given payload. | 
| void | setConnectionName(String name)Set the connection name (referenced in connections.xml) that REST requests
 should be directed to. | 
| void | setGenerateAnalyticsEvents(boolean value)Set the boolean value for indicating whether Analytics should be logged for a
 webservice call | 
| void | setRequestMethod(String method)Set the request method for the REST call. | 
| void | setRequestURI(String uri)Set the additional request URI | 
| void | setRetryLimit(int retries)Set the maximum retries any request should attempt before determining the
 request will not succeed. | 
static final String REQUEST_TYPE_GET
static final String REQUEST_TYPE_POST
static final String REQUEST_TYPE_PUT
static final String REQUEST_TYPE_DELETE
void addRequestProperty(String key,
                        String value)
key - must not be null.value - must not be null.void clearRequestProperties()
void removeRequestProperty(String key)
key - must not be null.java.util.Map<String,String> getRequestProperties()
String getResponseHeader(String key)
key - must not be null.java.util.Map<String,String> getResponseHeaders()
void setRequestMethod(String method)
method - should be either GET, POST, PUT, or DELETEString getRequestMethod()
int getRetryLimit()
void setRetryLimit(int retries)
retries - String getConnectionName()
void setConnectionName(String name)
name - String send(String payload)
     throws java.io.IOException
payload - java.io.IOExceptionRestWebServiceOperation.invoke(java.lang.String,
      java.util.Map)byte[] sendReceive(String payload)
            throws java.io.IOException
payload - java.io.IOExceptionRestWebServiceOperation.invoke(java.lang.String,
      java.util.Map)java.io.InputStream sendRequest(String payload)
                         throws java.io.IOException
ChunkedInputStreamclass to read the
 stream.
 
 See .6.1
payload - the payload to send to the server.java.io.IOExceptionjavax.microedition.io.HttpConnection getHttpConnection(String requestMethod,
                                                       String request,
                                                       Object httpHeadersValue)
                                                throws java.io.IOException
 
  // Create an instance of a RestServiceAdapter
  RestServiceAdapter restServiceAdapter = Model.createRestServiceAdapter();
  // Clear any previously set request properties, if any
  restServiceAdapter.clearRequestProperties();
  // Specify the type of request
  String requestMethod = RestServiceAdapter.REQUEST_TYPE_GET;
  // Get the connection end point from connections.xml
  String requestEndPoint = restServiceAdapter.getConnectionEndPoint("GeoIP");
  // Get the URI which is defined after the end point
  String requestURI = "/xml/" + someIpAddress;
  // The request is the end point + the URI being set
  String request = requestEndPoint + requestURI;
  // Specify some custom request headers
  HashMap httpHeadersValue = new HashMap();
  httpHeadersValue.put("Accept-Language", "en-US");
  httpHeadersValue.put("My-Custom-Header-Item", "CustomItem1");
  // Get the connection
  HttpConnection connection = restServiceAdapter.getHttpConnection(requestMethod, request, httpHeadersValue);
 
 requestMethod - should be either GET, POST, PUT, or DELETErequest - the fully qualified request (end point + request URI)httpHeadersValue - An Object that implements the Map interface. Its key/value pairs
          are assigned as request properties to the returned connection.java.io.IOExceptionHttpConnectionjava.io.OutputStream getOutputStream(javax.microedition.io.HttpConnection connection)
                              throws java.io.IOException
connection - Exceptionjava.io.IOExceptionHttpConnectionjava.io.InputStream getInputStream(javax.microedition.io.HttpConnection connection)
                            throws java.io.IOException
connection - java.io.IOExceptionHttpConnectionvoid close(javax.microedition.io.HttpConnection connection)
connection - HttpConnectionString getConnectionEndPoint(String connName)
connName - the connection name of the connection to find in connections.xmlint getResponseStatus()
String getHttpStatusMessage(int httpStatusCode)
httpStatusCode - a HTTP status code.String getResponseMessage()
String getResponseContentType()
void setRequestURI(String uri)
uri - String getRequestURI()
void setGenerateAnalyticsEvents(boolean value)
true- - if analytics should be generated for the webservice call
        false- If analytics should be suppressed for the webservice callboolean isGenerateAnalyticsEvents()