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

OData SDMConnectivity component - HttpRequest for Android application

Hi,

I am trying to consume a Odata Service from my Native Android Application.

I am following the same steps as described in OData SDK Document.

By Default, SDMConnectivity component is performing SUP Request. I need to change this to use HTTP/HTTPS Request for my Android Application. I couldnot find the way to do this, from the OData SDK.

For iOS Applicaiton, this is done using setRequest/SDMHTTPRequest. Any idea, how the same is achieved for Android application ?

Regards

Elavarasan S

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2012 at 02:07 PM

    1. Create the request URL that will be sent.

    String requestUrl = http://<Gateway_Host>:<Gateway_Port>/sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT/GetAvailableFlights?cityfrom= + cityFrom + "&cityto=" + cityTo + "&fromdate=" + fromDate + "&todate=" + toDate;
    DefaultHttpClient client = new DefaultHttpClient();
    client.getCredentialsProvider().setCredentials(AuthScope.ANY,
    new UsernamePasswordCredentials("<Gateway_User>", "<Gateway_Password>"));

    2. Create a Get request.

    HttpGet getRequest = new HttpGet();
    // buffer reader to read the response
    BufferedReader bufferedReader = null;
    // placeholder for the service response
    HttpResponse response = null;
    getRequest.setURI(new URI(requestUrl));
    getRequest.setHeader("Content-Type", "text/xml");
    getRequest.setHeader("Host", getRequest.getURI().getHost());
    5. Execute the request.
    response = client.execute(getRequest);

    I hope that helps

    Srinivas Divakarla

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 23, 2012 at 06:55 PM

    HI elavarasan,

    Please mark it as answered if that is solves your question and award points 😊

    Cheers,

    Srinivas Divakarla

    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.