我是新来的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);
}
}
}
谢谢,发生