This method returns the character is not a class object
Response response = target.request().header("X-Auth-Token", token).buildPost(entity).invoke();
int code = response.getStatus();
message = response.readEntity(String.class);
response.close();
/* System.out.println(code);
System.out.println(message);*/
} catch (Exception e) {
e.printStackTrace( );
}
return message;
The front desk can take this format
String response = request.postRequest();
JSONObject resObj = JSONObject.parseObject(response);// .fromObject(response);
JSONObject jsonObj = resObj.getJSONObject("result ");//General
if(jsonObj==null)
return null;
JSONArray jsArray = jsonObj.getJSONArray("operationLogList");//Set according to the returned character result
//Another need object class
Client client = getClient();
WebTarget webTarget = client. target(vimRestRootUrl).path(VDU_URL)
.path(vduUUID).path("detail");
Invocation.Builder invocationBuilder = webTarget
.request(ContentType.APPLICATION_JSON_UTF_8);
//This class method can also be automatically converted to json , the same name will be set automatically, but if the name is different, use @JsonProperty to convert
VduQueryResp resp = invocationBuilder.get(VduQueryResp.class);
return resp.getResult();//The returned VduVm class
////
package com.certusnet .nfv.mano.nfvo.vnfr.pojo;
import com.certusnet.nfv.mano.common.pojo.VduVm;
import com.certusnet.nfv.mano.rsclient.RestResp;
public class VduQueryResp extends RestResp {
/**Vdu对应的平台虚拟机信息*/
private VduVm result;
public VduVm getResult() {
return result;
}
public void setResult(VduVm result) {
this.result = result;
}
}
package com.certusnet.nfv.mano.rsclient;
public abstract class RestResp {
protected String retCode;
protected String msg;
public String getRetCode() {
return retCode;
}
public void setRetCode(String retCode) {
this.retCode = retCode;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.certusnet.nfv.mano.common.pojo;
import com.fasterxml.jackson.annotation.JsonProperty;
public class VduVm {
private String uuid;
@JsonProperty("vm_image")
private String vmImage;
@JsonProperty("cpu_number")
private String cpuNumber;
@JsonProperty("memory_size")
private String memorySize;
@JsonProperty("disk_size")
private String diskSize;
@JsonProperty("ip_addr")
private String ipAddr;
private String path;
private String status;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getVmImage() {
return vmImage;
}
public void setVmImage(String vmImage) {
this.vmImage = vmImage;
}
public String getCpuNumber() {
return cpuNumber;
}
public void setCpuNumber(String cpuNumber) {
this.cpuNumber = cpuNumber;
}
public String getMemorySize() {
return memorySize;
}
public void setMemorySize(String memorySize) {
this.memorySize = memorySize;
}
public String getDiskSize() {
return diskSize;
}
public void setDiskSize(String diskSize) {
this.diskSize = diskSize;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getIpAddr() {
return ipAddr;
}
public void setIpAddr(String ipAddr) {
this.ipAddr = ipAddr;
}
}
Rest Two processing methods of client data return
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326990215&siteId=291194637
Recommended
Ranking