Skip to Content
author's profile photo Former Member
Former Member

consuming oData web service and to post data using android native app


In my application(Android native application using oData sdk libs) I`m able to invoke the Web Service (WS) URL (ie) all three urls (service ,metadata and search) and also getting the result in auto invoked method onSuccess()


public void onSuccess(ISDMRequest aRequest, HttpResponse aHttpResponse) {

Log.w(TAG,"-----onSuccess-------- getRequestUrl*********************> "+ aRequest.getRequestUrl());

String respBody = "";

try {

final String entityString = EntityUtils.toString(aHttpResponse.getEntity());

final int cLength = 400;

final int len = entityString.length() < cLength ? entityString.length() : cLength;

respBody = entityString.substring(0, len);

Log.w(TAG, "-----onSuccess-------- ******EntityUtils***************> "+ respBody);

if (aRequest.getRequestUrl().equals(serviceURL)) {

Log.e("onSuccess", "serviceURL");

dataServiceDocument = (SDMODataServiceDocument) this.getParser().parseSDMODataServiceDocumentXML(entityString);

} else if (aRequest.getRequestUrl().equals(metadataURL)) {

Log.e("onSuccess", "metadataURL");

dataSchema = (SDMODataSchema) this.getParser().parseSDMODataSchemaXML(entityString, dataServiceDocument);

} else if (aRequest.getRequestUrl().equals(searchURL)) {

Log.e("onSuccess", "searchURL");

List<ISDMODataEntry> entries = this.getParser().parseSDMODataEntriesXML(entityString, "DefectCollection",dataSchema);

System.out.println("SEUCESS ---------------------------- > "+ entries.size());

List<ISDMODataProperty> properties = entries.get(0).getPropertiesData();

System.out.println("properties -------size--------------------- > "+ properties.size());


} catch (Exception e) {

Log.e(TAG, "##Exception "+ e.getMessage());




1) I would like to know difference way to parse the obtained xml using oData sdk.

2) And while posting how can we construct the post data as xml using oData sdk , currently I`m posting by constructing/hard cording the xml structure as String is will not be possible for huge data.

Kindly share some links/documents related to queries


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 07, 2012 at 05:21 PM

    Hi Yougesh,

    You can try constructing the request xls using one of the recieved entries.

    // Declare the list as global Or store to catch.

    static List<ISDMODataEntry> entries = null;

    // Parse the data and store to list.

    public void onSuccess(ISDMRequest aRequest, HttpResponse aResponse) {

    SDMLogger lg = getLogger();
    String entriesXML = null;

    try {
    entriesXML = EntityUtils.toString(aResponse.getEntity(), "UTF-8");
    } catch (IOException e) {
    getLogger().e(TAG, "Entity conversion", e);

    try {
    entries = getParser()
    .parseSDMODataEntriesXML(entriesXML, collectionId,

    } catch (IllegalArgumentException e) {

    } catch (SDMParserException e) {


    // While building request get any of the entry and modify the properties.
    ISDMRequest request = new SDMBaseRequest();
    ISDMODataEntry entry = entries.get(0);
    entry.putPropertyValue("propertyName", "value");
    String xmlData= entry.toXMLString();
    byte[] data = null;
    try {
    data = xmlData.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {


    Hope it work out.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.