【问题标题】:Getting java.io.IoException while calling .net web service from my java code从我的 java 代码调用 .net Web 服务时获取 java.io.IoException
【发布时间】:2014-03-20 10:38:34
【问题描述】:

我的代码:

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;
import android.widget.Toast;

public class CallSoap {
    public final String SOAP_ACTION = "http://tempuri.org/SendMessage";

    public final String OPERATION_NAME = "SendMessage";

    public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

    public final String SOAP_ADDRESS = "http://omega-solutions.in/ExpertsApp.asmx";

    public CallSoap() {
    }

    public String Call(String deviceid, String msg) {
        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
                OPERATION_NAME);
        PropertyInfo pi = new PropertyInfo();
        pi.setName("deviceid");
        pi.setValue(deviceid);
        pi.setType(String.class);
        request.addProperty(pi);
        pi = new PropertyInfo();
        pi.setName("msg");
        pi.setValue(msg);
        pi.setType(String.class);
        request.addProperty(pi);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        Object response = null;
        try {



            httpTransport.call(SOAP_ACTION, envelope);






            response = envelope.getResponse();
            Log.e("after", "" + "after");
        } catch (Exception exception) {

            Log.e("before", "" + "before" + exception.toString());
            response = exception.toString();
        }
        return response.toString();
    }
}

当我运行这段代码时

httpTransport.call(SOAP_ACTION, envelope);

在上面的代码行之后我得到java.io.ioException

【问题讨论】:

  • 发布您的 logcat,需要更多信息。
  • 我得到的只是 java.io.ioException 没有别的
  • 我不确定这个异常。顺便说一句,您会遇到许多其他异常,例如 networkOnMainThread ...您应该使用 asynctask 进行网络操作。我建议您更改整个代码。
  • 试试这个link 参考

标签: android ksoap


【解决方案1】:

请检查你的web服务的web方法是否关闭了连接。因为我也遇到了同样的问题,但是在我的web服务中关闭了我的web方法的sql连接后,它已经被重新处理了... . 最好的.!!!!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多