SDMRequest

An SDMRequest object wraps all the information 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 by using the ISDMNetListener interface. The connectivity component provides an interface called ISDMRequest and a base implementation of it, called SDMBaseRequest. The applications have to extend this interface when creating new application specific requests.

ISDMRequest

    void setRequestUrl(String url); 
    String getRequestUrl(); 
    void setRequestMethod(final int reqType); 
    int getRequestMethod();
    byte[] getData();
    Hashtable getHeaders();
    void setData(byte[] data);
    void setHeaders(Map<String,String> headers); 
    void setPriority(final int value);
    int getPriority();
    boolean useCookies();
    ISDMNetListener getListener();
    void setListener(ISDMNetListener listener);
    void setStreamEnabled(boolean streamEnabled);
    void SetDataStream(InputStream stream)

The setStreamEnabled 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 connectivity layer notifies the client about the result of a request by the ISDMNetListener interface. Usage of this feature is not mandatory, but it is recommended to be able to handle incidental errors. Methods available in the ISDMNetListener interface:
ISDMNetListener

	void onSuccess(ISDMRequest  aRequest, ISDMResponse aResponse);
	void onError(ISDMRequest aRequest, ISDMResponse aResponse, SDMRequestStateElement 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 ISDMRequestStateElement interface:
ISDMRequestStateElement

	int getHttpStatusCode();
	int getErrorCode();
	Exception getException();
    org.apache.http.HttpResponse getHttpResponse()	
    void setHttpStatusCode(final int httpStatus);
	void setErrorCode(final int code);
	void setException(final Exception aException);
    void setHttpResponse(org.apache.http.HttpResponse aResponse)
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.getCookieString());
	byte[] content = aResponse.getContent();
	String response = new String(content);
	System.out.println("Received content:" + response);
	//get the headers
	Hashtable headers = aResponse.getHeaders();
}

Example for uploading data stream from device to server
while((bytesRecvd = resp.getDataStream(buf,102400))>0)
{
   try {
         b.append(new String(buf).trim());
         buf = new byte[102400];
     }
Catch(){
…
}
}