安卓使用SOAP调用WebService

时间:2022-08-01 22:36:43

String namespace = “http://Service.com/“;
String url=”http://”+webserviceIp+”:8080/CareServer/CareServer?wsdl”

SoapObject soapObject = new SoapObject(namespace, “uploadTalk”);
soapObject.addProperty(“eno”, eno);
soapObject.addProperty(“TalkInfo”, TalkInfo);
soapObject.addProperty(“clientname”,clientname);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
envelope.dotNet = false;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE httpTranstation = new HttpTransportSE(url,3000);
try {
httpTranstation.call(null, envelope);
Object result = envelope.getResponse();//服务端返回值
}catch(Exception e){
//e.printStackTrace();
String msg=”“;
if (e instanceof java.net.SocketTimeoutException) {
msg = “连接服务器超时,请检查网络”;
} else if (e instanceof java.net.UnknownHostException) {
msg = “未知服务器,请检查配置”;
}
e.printStackTrace();
Log.i(“connectwebservice”,Log.getStackTraceString(e));
Log.i(“connectwebservice”,”error”);
//Log.i(“connectWebService”, e.getMessage());
}