【发布时间】: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 参考