我的代码:
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
。
答案 0 :(得分:0)
请检查您的Web服务的Web方法是否已关闭连接。因为我也遇到了同样的问题,但在我的Web服务中关闭了我的Web方法的sql连接后,它已被重新启用...最好的。!!!!!