SDMResponse

An SDMResponse object wraps all the information needed by the connectivity library to be respond back to the application.

The connectivity component provides an interface called ISDMResponse. Available SDMResponse APIs are:

ISDMResponse

    boolean isDataAvailable();
    String getCookie();
    int getCurrentOffset();
    void setCorelationId(String coRelationId);
    String getCorelationId();
    int getDataStream(byte[] buffer, int chunkSize);
    int getDataStream(byte[] buffer, int chunkSize, int offset, String cookie);

The getDataStream API is used by the application to retrieve the data stream. This API returns the length of data buffer, and the application invokes this API until the length of buffer stream is equal to 0.

Example for successful streaming response received by application

public void GetOperation()
{
…
    String collectionUrl = "http://vmw3815.wdf.sap.corp:50009/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/FlightCollection/";
    getCollection.setRequestUrl(collectionUrl);
    getCollection.setRequestMethod(SDMBaseRequest.REQUEST_METHOD_GET);
    getCollection.setListener(this);
    getCollection.setStreamEnabled(true);

    reqMan.makeRequest(getCollection);
…
}

@Override
public void onSuccess(ISDMRequest aRequest, ISDMResponse aResponse) 
{
    // TODO Auto-generated method stub
    HttpEntity responseEntity = aResponse.getEntity();
    SDMResponse resp = (SDMResponse)aResponse;
    String reponse = "";
if(aRequest.equals(getCollection))
{
    StringBuffer b = new StringBuffer();
    int bytesRecvd = 0;
    byte[] buf = new byte[102400];


while((bytesRecvd = resp.getDataStream(buf,102400))>0)
{

    try {
        b.append(new String(buf).trim());
        buf = new byte[102400];
 }
    catch (IOException e) {
        e.printStackTrace();
		}
	}

Log.i("NewFlight", "Final streamed data: "+ b.toString());

	response = b.toString();

    ISDMODataEntry dEntry;
	try {
dEntry = parser.parseSDMODataEntriesXML(response, "FlightCollection", cache.getSDMODataSchema()).get(0);
		} 
catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} 
catch (SDMParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}