|
Oracle Fusion Middleware Java API Reference for Oracle Mobile Application Framework 2.0.0.0.0 E36392-01 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface RestServiceAdapter
| Field Summary | |
|---|---|
static String |
REQUEST_TYPE_DELETE
|
static String |
REQUEST_TYPE_GET
|
static String |
REQUEST_TYPE_POST
|
static String |
REQUEST_TYPE_PUT
|
| Method Summary | |
|---|---|
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. |
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. |
java.util.HashMap |
getRequestProperties()
|
String |
getRequestType()
|
String |
getRequestURI()
|
String |
getResponseContentType()
Retrieve the content type of the response |
String |
getResponseHeader(String key)
Retrieve response header |
java.util.HashMap |
getResponseHeaders()
|
int |
getResponseStatus()
|
int |
getRetryLimit()
|
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 |
void |
setConnectionName(String name)
Set the connection name (referenced in connections.xml) that REST requests should be directed to. |
void |
setRequestType(String getPostPutDelete)
Set the request type 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. |
| Field Detail |
|---|
static final String REQUEST_TYPE_GET
static final String REQUEST_TYPE_POST
static final String REQUEST_TYPE_PUT
static final String REQUEST_TYPE_DELETE
| Method Detail |
|---|
void addRequestProperty(String key,
String value)
key - value - void clearRequestProperties()
void removeRequestProperty(String key)
key - java.util.HashMap getRequestProperties()
String getResponseHeader(String key)
key -
java.util.HashMap getResponseHeaders()
void setRequestType(String getPostPutDelete)
getPostPutDelete - should be either GET, POST, PUT, or DELETEString getRequestType()
int getRetryLimit()
void setRetryLimit(int retries)
retries - String getConnectionName()
void setConnectionName(String name)
name -
String send(String payload)
throws Exception
payload -
ExceptionRestWebServiceOperation.invoke(java.lang.String,
java.util.Map),
ADFbcRestWebServiceOperation.invoke(java.lang.String,
java.util.Map)
byte[] sendReceive(String payload)
throws Exception
payload -
ExceptionRestWebServiceOperation.invoke(java.lang.String,
java.util.Map),
ADFbcRestWebServiceOperation.invoke(java.lang.String,
java.util.Map)
javax.microedition.io.HttpConnection getHttpConnection(String requestMethod,
String request,
Object httpHeadersValue)
throws Exception
// 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.
ExceptionHttpConnection
java.io.OutputStream getOutputStream(javax.microedition.io.HttpConnection connection)
throws Exception
connection -
ExceptionHttpConnection
java.io.InputStream getInputStream(javax.microedition.io.HttpConnection connection)
throws Exception
connection -
ExceptionHttpConnectionvoid close(javax.microedition.io.HttpConnection connection)
connection -
ExceptionHttpConnection
String getConnectionEndPoint(String connName)
throws Exception
connName - the connection name of the connection to find in connections.xml
Exceptionint getResponseStatus()
String getResponseContentType()
void setRequestURI(String uri)
uri - String getRequestURI()
|
Oracle Fusion Middleware Java API Reference for Oracle Mobile Application Framework 2.0.0.0.0 E36392-01 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||