我是新來的android,我想調用wcf web服務。我找到了ksoap2庫並聲明應用我找到的示例。該應用失敗,出現以下錯誤消息:java.net.SocketTimeoutException:連接超時。 我已經設置用戶權限的manafist文件這樣的:在Android應用上使用ksoap2調用wcf web服務失敗,出現以下錯誤java.net.SocketTimeoutException:連接超時
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
我還添加從仿真器的代理,端口,用戶名和密碼設置APP->無線和網絡 - >移動網絡 - >接入點名稱。 我還增加了從運行配置如下行額外的仿真器命令行選項:
-dns-server ns15.unitechost.in
但還是沒有工作,任何幫助,將不勝感激。
更新
我已經配置了代理使用以下命令啓動AVD時,在命令行設置:
emulator -avd <avd_name> [-<option> [<value>]] ... [-<qemu args>]
現在,我得到以下異常:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT HTTP/1.1 500 [email protected]:1 in [email protected])
我已經看到了使用ksoap2來使用.asmx web服務的例子,這是否也可以在.svc web服務上完成? 我使用附帶的代碼,我從一個有若例子:
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.util.Log;
import android.widget.TextView;
public class Main extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://tempuri.org/Istock/getCountry";
private static final String OPERATION_NAME = "getCountry";
private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
private static final String SOAP_ADDRESS = "http://127.0.0.1:8080/Service1.svc";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
setContentView(textView);
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
textView.setText(response.toString());
System.out.println(response.toString());
}
catch (Exception exception)
{
String exceptionStr=exception.toString();
textView.setText(exceptionStr);
System.out.println(exceptionStr);
Log.i("TAG",exceptionStr);
}
}
}
謝謝,發生