1

I am getting no errors in LogCat. The ip showing in code is localhost ip address. I have availability of internet in my AVD.

My MainActivity.java is :

public class MainActivity extends Activity {

private static final String SOAP_ACTION = "http://tempuri.org/add";
private static final String METHOD_NAME = "add";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://101.63.111.137/yash/DemoService.asmx";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    Button callMe = (Button) findViewById(R.id.b1);
    callMe.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            String responseData = getData();
            ((TextView) findViewById(R.id.textView1)).setText("Response Received is: " + responseData);
        }

    });

}

private String getData() {

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    PropertyInfo pi = new PropertyInfo();
    pi.setName("i");
    pi.setValue(((EditText) findViewById(R.id.e1)).getText().toString());
    pi.setType(int.class);
    request.addProperty(pi);

    PropertyInfo pi2 = new PropertyInfo();
    pi2.setName("j");
    pi2.setValue(((EditText) findViewById(R.id.e2)).getText().toString());
    pi2.setType(int.class);
    request.addProperty(pi2);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport=new HttpTransportSE(URL);
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        return response.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return e.toString();
    }
}

}

I have added these lines in AndroidManifest.xml

Thanks in advance.

Yash
  • 634
  • 1
  • 6
  • 17

1 Answers1

3

Have you added INTERNET_ACCESS permission to your Manifest?

 <manifest xlmns:android...>
   ...
   <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 </manifest>

SocketException

Community
  • 1
  • 1
Enrichman
  • 11,157
  • 11
  • 67
  • 101
  • After adding these line permission line It is showing connection refused exception.: Java.net.ConnectException. – Yash Feb 10 '13 at 11:54