hi experts,
i am very new to android . i just want to call a webservice from android .For this i have a c#.net webservice with one menthod helloAndroid(String str). I am trying to call this web service by using following code but i am getting SocketException.
Please help me its urgent
the code is follows..
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class CommSer extends Activity {
/** Called when the activity is first created. */
//private static final String SOAP_ACTION = "HelloYou"; http://192.168.1.66/Applications/WebSite10
private static final String SOAP_ACTION = "http://192.168.1.66/Applications/WebSite10";
private static final String METHOD_NAME = "HelloAndroid";
//private static final String NAMESPACE = "urn:HelloYou";http://192.168.1.66
private static final String NAMESPACE = "http://192.168.1.66/";
private static final String URL = "http://192.168.1.66/Applications/WebSite10/Service.asmx";
private Object resultRequestSOAP = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
setContentView(R.layout.main);
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// ObjectOutputStream oos = new ObjectOutputStream(baos);
//oos.writeObject(map);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//SoapObject
request.addProperty("str","param");
Toast.makeText(getBaseContext(), "1",
Toast.LENGTH_SHORT).show();
//request.addProperty("lastname", "Williams");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
Toast.makeText(getBaseContext(), "2",
Toast.LENGTH_LONG).show();
//HttpTransport androidHttpTransport = new HttpTransport(URL);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
resultRequestSOAP = envelope.getResponse();
Toast.makeText(getBaseContext(), resultRequestSOAP.toString(),
Toast.LENGTH_LONG).show();
//String[] results = (String[]) resultRequestSOAP;
//tv.setText( results[0]);
}
catch (Exception aE)
{
//aE.printStackTrace ();;
Toast.makeText(getBaseContext(), aE.toString(),
Toast.LENGTH_LONG).show();
}
}
}

