使用kso​​ap2与以下错误java.net.SocketTimeoutException失败的Andr​​oid应用程序调用WCF Web服务:连接超时 [英] invoke wcf web service using ksoap2 on android app failed with the following error java.net.SocketTimeoutException: Connection timeout

查看:509
本文介绍了使用kso​​ap2与以下错误java.net.SocketTimeoutException失败的Andr​​oid应用程序调用WCF Web服务:连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid和我想WCF Web服务调用。我发现ksoap2库,并指出申请我found.The应用程序失败,出现以下错误消息的例子:java.net.SocketTimeoutException:连接超时。
我已经设定用户权限上这样的manafist文件:

I'm new to android and I wanted to call wcf web service. I have found ksoap2 library and stated to apply the examples I found.The app failed with the following error message: java.net.SocketTimeoutException: Connection timeout. I had set user permission on the manafist file like that:

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

我也加从仿真器代理,端口,用户名和密码设置APP->无线和网络 - >移动网络 - >接入点名称。
我还添加了以下行从运行配置额外的仿真器命令行选项:

I have also add the proxy, port, username and password from the emulator setting app-> wireless and network->mobile networks->Access Point Names. I have also added the following line from run configuration to additional emulator command line options:

-dns-server ns15.unitechost.in

但它仍然没有工作,任何帮助将是AP preciated。

But still it did not work, any help would be appreciated.

更新

我已经配置代理服务器使用以下命令启动AVD时,在命令行设置:

I have configured the proxy setting from command line when starting AVD with the following command:

emulator -avd <avd_name> [-<option> [<value>]] ... [-<qemu args>]

现在我得到了以下异常:

Now I got the following exception:

org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT HTTP/1.1 500 Int...@11:1 in java.io.InputStreamReader@40531d48)

我已经看到了消费使用kso​​ap2的.asmx Web服务的例子,可以在此对.SVC Web服务来完成呢?
我使用的连接code,我从一个有若例子:

I have seen examples for consuming .asmx web service using ksoap2, can this be done on .svc web service as well? I'm using the attached code, I got from one if the examples:

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);
        }

    }

}

谢谢,

推荐答案

虽然这可能是晚了一点,这是固定的对我来说:

Although this may be a little late, this is what fixed it for me:

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);

注意第二个参数,它是超时值。

Notice the second parameter, which is the timeout value.

我必须承认强硬,我不知道尺度去与这个值,但我认为这是在毫秒为单位。

I must admit tough, that i do not know the scale to go with this value, but I think this is measured in milliseconds.

这篇关于使用kso​​ap2与以下错误java.net.SocketTimeoutException失败的Andr​​oid应用程序调用WCF Web服务:连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆