public String gpsShip(Long id) {
String returnStr = "";
// 根据接口消息ID来获取是哪一个接口
TmsInterfaceLog log = this.commonDao.load(TmsInterfaceLog.class, id);
//提供接口的地址
String url = "http://111.222.58.114:8274/WebService/TMSWebService.asmx";
//域名,这是在server定义的命名空间
//<wsdl:definitions targetNamespace="http://tempuri.org/">
String soapaction = "http://tempuri.org/";
String City = log.getRequestContent().toString();
Service service = new Service();
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
//设置要调用哪个方法
call.setOperationName(new QName(soapaction, "TMSDespatch"));
//设置要传递的参数
call.addParameter(new QName(soapaction, "TMSContent"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
//(标准的类型)
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapaction + "TMSDespatch");
//调用方法并传递参数
String result = (String) call.invoke(new Object[] { City });
// 判断处理是否成功
if (!"REQUEST_SUCCEED".equals(result)) {
if ("REQUEST_NOFONDVEHICLE".equals(result)) {
returnStr = "库里无该车辆信息";
} else if ("REQUEST_FORMATERROR".equals(result)) {
returnStr = "接收到的xml信息格式有误";
} else {
returnStr = "失败--其他原因";
}
}
// 保存错误信息
log.setErrorMessage(returnStr);
commonDao.store(log);
System.out.println(result);
} catch (Exception ex) {
ex.printStackTrace();
}
return returnStr;
}