END_TAG exception while calling WCF WebService from Android using KSOAP2?
Posted
by sunil
on Stack Overflow
See other posts from Stack Overflow
or by sunil
Published on 2010-06-07T14:25:02Z
Indexed on
2010/06/08
9:52 UTC
Read the original article
Hit count: 393
Hi,
I am trying to call a WCF Web Service from Android using KSOAP2 library. But I am getting this END_TAG exception. I have followed this thread to call WCF Web Service but still no result. I am passing "urn:TestingWcf/GetNames" as SOAP_ACTION, does this causes problem in Android since the error occurs at the statement "aht.call(SOAP_ACTION, envelope)" where aht is AndroidHttpTransport class object.
Can someone let me know what the problem may be?
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Ksoap2Test extends Activity {
private static final String METHOD_NAME = "GetNamesJsonWithParam"
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://192.168.3.61/BattleEmpire.Service/TestingWcf.svc/basic";
final String SOAP_ACTION = "urn:TestingWcf/GetNamesJsonWithParam";
TextView tv;
StringBuilder sb;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
tv = new TextView(this);
sb = new StringBuilder();
call();
tv.setText(sb.toString());
setContentView(tv);
}
public void call()
{
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("imran", "Qing");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
System.out.println("Request " + envelope.toString());
//HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
aht.call(SOAP_ACTION, envelope);
//aht.debug = true;
/*HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);*/
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
//to get the data
String resultData = result.toString();
// 0 is the first object of data
sb.append(resultData + "\n");
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
System.out.println(resultsRequestSOAP.toString());
}
catch (Exception e)
{
e.printStackTrace();
sb.append("Error:\n" + e.getMessage() + "\n");
}
}
} `
© Stack Overflow or respective owner