1、请求将参数标签化
@PostMapping("/xxx")
public Map<String, Object> applyXXX(@RequestBody Entity entity){
Map<String, Object> result = new HashMap<>();
if (StringUtils.isBlank(实体.getXm())){
result.put("code", "003");
result.put("message","姓名为空!请检查");
return result;
}
if (StringUtils.isBlank(实体.getCard())){
result.put("code", "003");
result.put("message","证件号码为空!请检查");
return result;
}
StringBuffer strXml = new StringBuffer();
strXml.append("<操作*>xx操作</操作*>")
.append("<姓名*>").append(实体.getXm()).append("</姓名*>")
.append("<证件类型*>").append(实体.getZjlx()).append("</证件类型*>")
.append("<证件号码*>").append(实体.getCard()).append("</证件号码*>");
try {
Call call = (Call) (new Service()).createCall();
call.setTargetEndpointAddress(new URL(url));
call.setOperationName(new QName("url", "接口名"));
call.setTimeout(30000);
String res = (String) call.invoke(new String[]{strXml.toString()});
System.out.println(res);
log.info("<<xxxxx>>接口调用返回结果:" + res);
res = res.replace("<ERR>", "").replace("</ERR>", "");
if ("00".equals(res)) {
result.put("code", res);
result.put("message", "调用成功");
} else if ("01".equals(res)) {
result.put("code", res);
result.put("message", "已存在");
} else {
result.put("code", "002");
result.put("message", "调用失败,失败原因:" + res);
}
} catch (ServiceException e) {
log.error(e.getMessage());
result.put("code","003");
result.put("message",ERROR);
return result;
} catch (MalformedURLException e) {
log.error(e.getMessage());
result.put("code","003");
result.put("message",ERROR);
return result;
} catch (RemoteException e) {
log.error(e.getMessage());
result.put("code","003");
result.put("message",ERROR);
return result;
}
return result;
}