Android 从java代码调用.net web服务时获取java.io.IoException
我的代码:Android 从java代码调用.net web服务时获取java.io.IoException,android,ksoap,Android,Ksoap,我的代码: 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.ut
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。请检查您的web服务的web方法是否已关闭连接。因为我也遇到了相同的问题,但在关闭web服务中的web方法的sql连接后,它已被重新访问。。。。一切都好 发布你的日志,需要更多信息。我只得到java.io.ioException什么都没有。我不确定这个异常。顺便说一下,你会得到很多其他的异常,比如networkOnMainThread。。。您应该使用asynctask进行网络操作。我建议您更改整个代码。请尝试此操作以获取参考