SDMRequest

An SDMRequest object wraps all the information which is needed by the connectivity library to be able to perform the requests. The connectivity library interacts with the request object to query the necessary information about the headers, the post data, and so on.

The connectivity layer also uses the request object to notify the application about the result of the request using the ISDMNetListener interface. The connectivity component provides an interface called the ISDMRequest and a base implementation of it called the SDMBaseRequest. The applications have to extend this base class when creating new application specific requests. The ISDMRequest interface defines the following public APIs:
ISDMRequest

void setRequestUrl(final String aUrl)
String getRequestUrl()
void setRequestMethod(final int aRequestMethod)
int getRequestMethod()
byte[] getData()
void setPriority(final int aPriority)
int getPriority()
boolean useCookies()
void setListener(final ISDMNetListener aListener)
ISDMNetListener getListener()
boolean hasPostData()
void postData(OutputStream os)
void setHeaders(final Hashtable aHashtable)
Hashtable getHeaders()
void appendHeaders(final Hashtable aHashtable)
void appendHeader(final String aHeaderName, final String aHeaderValue)
void setEtag(String eTag, int eTagHeader)
void enableStreaming(boolean tobestreamed)
boolean isStreamingEnabled()
InputStream getDataStream()
void setDataStream(InputStream iStream)

The enableStreaming API is used by the application to enable streaming for downloading large amount of data from server to device.

The SetDataStream API is used by the application to enable streaming for uploading large amount of data from device to server.

The ISDMNetListener interface can be used by the client to be notified by the connectivity layer about the result of a request. Usage of this feature is not mandatory, however, you can handle incidental errors with it. Methods available in the ISDMNetListener interface:
ISDMNetListener

void onSuccess(ISDMRequest aRequest, IHttpResponse aResponse)
void onError(ISDMRequest aRequest, ISDMResponse aResponse, ISDMRequestStateElement aRequestStateElement)
The role of the SDMRequestStateElement object used by the connectivity library is to provide the application with more detail on the occurred error. Methods available in SDMRequestStateElement object:
ISDMRequestStateElement

int getErrorCode()
void setErrorCode(final int code)
int getHttpStatusCode()
void setHttpStatusCode(final int httpStatus)
Exception getException()
void setException(final Exception aException)
String getRedirectLocation()
IHttpResponse getResponse()
Example for successful response received by application from EIS

     public void onSuccess(ISDMRequest  aRequest, SDMHttpResponse aResponse) {
	 System.out.println("Http response status code:" + aResponse.getStatusCode());
	 System.out.println("Cookie string:" + aResponse.getCookie());
	 byte[] content = aResponse.getContent();
	 String response = new String(content);
	 System.out.println("Received content:" + response);
	 //get the headers
	 Hashtable headers = aResponse.getHeaders();
}
Example for data streaming request made by application

     final ISDMRequest request = new SDMBaseRequest();

     Hashtable headers = new Hashtable();
     headers.put("Content-Type", "application/atom+xml");
     request.setHeaders(headers);
     request.setPriority(ISDMRequest.PRIORITY_HIGH);
     request.setRequestMethod(ISDMRequest.REQUEST_METHOD_GET);
     request.setRequestUrl(url);
     request.setListener(listener);
     request.enableStreaming(true);
     requestManager.makeRequest(request);
}