1
votes

I'm trying to write a java code on an Android emulator that will send a string to a web service writen in c#.

Android code:

    HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod


    try {
        // Add your data
        List nameValuePairs = new ArrayList(2);
        nameValuePairs.add(new BasicNameValuePair("json", name));
      //  nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

Also tried:

    HttpPost httppost = new HttpPost("http://192.168.2.1:53811/WinnerSite/WebService.asm/MyMethod

The web-service is on the same machine as the emulator. MyMethod is accessable through:

http://localhost:53811/WinnerSite/WebService.asmx/MyMethod

Does someine ahs an idea? The code exits on the "httpclient.execute(httppost);" line The eclipse shows: "ActivityThread.prefo Source not found."

I have already solve a persmission problem (adding a note to the emolator's xml)

Thanks,

1
It's not clear to me what your question is. You have some kind of error running the app, or building the app? "The eclipse shows..." is terribly vague. Could you post the full error and explain at what stage you see it?Jim Blackler

1 Answers

1
votes

When you want to use the network, you should add network access permission in your AndroidManifest.xml.

Your problem seems to be complex. Check your client app and web service separately to assure they are both correct.

Your codes posted seems to be correct. But your error message "ActivityThread.prefo Source not found." is too weak... Please provide more info.