1

i'm using .net webservice to catch response which i am getting from Android Application. I am returning below line From android application

HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(
                "http://10.0.2.2:51889/OMS/WebServices/Service.asmx/Test");

    List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
    nameValuePair.add(new BasicNameValuePair("email", "abc"));
    nameValuePair.add(new BasicNameValuePair("pwd", "123"));


    // Url Encoding the POST parameters
    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
    } catch (UnsupportedEncodingException e) {
        // writing error to Log
        e.printStackTrace();
    }

    // Making HTTP Request
    try {
        HttpResponse response = httpClient.execute(httpPost);


    } catch (ClientProtocolException e) {
        // writing exception to log
        e.printStackTrace();

    } catch (IOException e) {
        // writing exception to log
        e.printStackTrace();
    }

how can i get response of this in .net web service?

i get the data like this from androidenter image description here

so how can i get that data in C#.net???

shivani patel
  • 225
  • 1
  • 8
  • 22
  • .net webservice to catch response or request?? it should be request. – Nirav Tukadiya Jan 09 '13 at 11:45
  • no it is response return from android app.. – shivani patel Jan 09 '13 at 11:47
  • response from Anroid application??? Are you running a HTTP server in app or how do you call from the .net application to android application? From what I see you are issuing a HTTP POST to the server from android? – Kolja Jan 09 '13 at 11:59
  • I want to send data from android to sql server via asp.net web service... – shivani patel Jan 09 '13 at 12:03
  • @shivanipatel : if you want to send data from android to asp.net service then it's depend on how you have created your service it accept json string from client, xml from client or just as parameters from android device ? what your webservice accept as params ? – ρяσѕρєя K Jan 09 '13 at 12:06
  • just to proof that I got you right. The android application issues a HTTP POST request to some server (no yours), gets the response and the you want to sent that response to your asp.net webservice? – Kolja Jan 09 '13 at 12:08
  • 1
    ahh ok, this might be the right thing for you:http://msdn.microsoft.com/en-us/library/dd203052.aspx – Kolja Jan 09 '13 at 12:12
  • +1 for above link @Kolja – Arun Manjhi Jan 09 '13 at 12:25
  • 1
    I know this is an old thread.Try this [link][1] it may help. [1]: http://stackoverflow.com/questions/4088625/net-simplest-way-to-send-post-with-data-and-read-response/19448979#19448979 – Murali Oct 18 '13 at 12:19

2 Answers2

0

Check out this here is the complete tutorial for .net - Android Connection.

And to get Response from android application to your webservice Ksoap will be useful to you. Here is Complete Ksoap Tutorial.please go through it. Hope it will help.

Nirav Tukadiya
  • 3,367
  • 1
  • 18
  • 36
0

Your Webservice seems to be a Soap WS, because of the ASMX. SOAP is a Microsoft propietary protocol, and you cannot consume it as a HttpRequest.

You need to use an external library to consume .Net SOAP WebServices like KSOAP.

Otherwise, you can create a Net Rest Service, and then you can call it directly as an HTTP request, using POST, PUT, DELETE, GET methods

noni
  • 2,927
  • 19
  • 18
  • SOAP is NOT a Microsoft propietary protocol. The specs are done by a W3C working group and can be found here: http://www.w3.org/TR/soap/ If you are willing to can generate the needed XML payload and pass it to the server via a HTTP POST request. You don't need an external library like KSOAP but it makes it much easiert. But generate such a message from a template might also be possible since he only needs a single operation. – Kolja Jan 09 '13 at 13:27
  • True, I've forgotten that. – noni Jan 09 '13 at 13:31