Hey All,
I want to call a .net web service from android using kshop2 But I get
a Error SocketException:Activity time out
Please Help Me....
My code.
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://192.168.1.120:2089/WebSite4/
WebService.asmx";
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.text1);
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("a");
pi.setValue(8);
pi.setType(int.class);
Request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("b");
pi2.setValue(36);
pi2.setType(int.class);
Request.addProperty(pi2);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
@SuppressWarnings("deprecation")
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
try
{
//tv.setText("Hello Try1...!");
androidHttpTransport.call(SOAP_ACTION, envelope);
//tv.setText("Hello Try2...!");
SoapObject response = (SoapObject)envelope.getResponse();
// tv.setText("Hello Try3...!");
int result =
Integer.parseInt(response.getProperty(0).toString());
//tv.setText("Hello Try4...!");
}
catch(Exception E)
{
tv.setText("ERROR:" + E.getClass().getName() + ":" +
E.getMessage());
// tv.setText("Hello Catch...!");
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en