我有一个ResponseModel类,我想发送它的对象以响应休息。但我收到此错误:Java类com.tcs.srl.message.model.ResponseModel的消息正文编写器,Java类型类com.tcs.srl.message.model.ResponseModel和MIME媒体类型application / json是找不到
package com.tcs.DataShare.WebService;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.*;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.tcs.DataShare.Client.DataShareServiceClient;
import com.tcs.DataShare.Client.GetFilesOnLocal;
import com.tcs.DataShare.Constants.DataShareConstants;
import com.tcs.srl.message.model.ResponseModel;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
@Path("/ConfigureAndrew")
public class ConfigureAndrew {
private static final Logger LOGGER = LoggerFactory
.getLogger(ConfigureAndrew.class);
private ClientResponse response;
@Path("/configureAndrew")
@POST
//@Produces("application/octet-stream")
// @Produces("application/xml")
@Produces(MediaType.APPLICATION_JSON)
public Response configureAndrew(@Context HttpServletRequest requestObj,
String serviceData) {
System.out.println("methods");
LOGGER.debug("Inside Configure Andrew web service: ");
JSONParser parser = new JSONParser();
ResponseModel result = new ResponseModel();
// JSONObject result=null;
String isSuccess = "false";
try {
String headerString = requestObj.getHeader("header");
JSONObject serviceJSON = (JSONObject) parser.parse(serviceData);
String datashareURL = (String) serviceJSON
.get(DataShareConstants.DATASHARE_URL);
String datasharePort = (String) serviceJSON
.get(DataShareConstants.DATASHARE_PORT);
System.out.println("datasharePort: " + datasharePort);
String servicename = (String) serviceJSON
.get(DataShareConstants.SERVICE_NAME);
String appname = (String) serviceJSON
.get(DataShareConstants.APP_NAME);
String version = (String) serviceJSON
.get(DataShareConstants.APP_VERSION);
String path = (String) serviceJSON.get(DataShareConstants.APP_PATH);
DataShareServiceClient dataShareServiceClient = new DataShareServiceClient(
datashareURL, datasharePort, servicename);
InputStream inputStream = dataShareServiceClient
.zipFolderWithSubsequestFolder(path);
if (inputStream.available() != 0) {
System.out.println("In the input stream");
GetFilesOnLocal getFilesOnLocal = new GetFilesOnLocal();
result = getFilesOnLocal.getFiles(inputStream, result);
LOGGER.debug("Input stream contains data");
} else {
LOGGER.error("Input stream is empty");
System.out.println("error in input stream");
}
LOGGER.debug("DatashareServices :completed configure Andrew");
isSuccess = "true";
result.setSuccess("true");
result.setErrors(null);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("DatashareServices :configureAndrew service failed "
+ e);
isSuccess = "false";
result.getErrors().add("Error in configureAndrew method");
}
return Response.status(200).entity(result).build();
}
}
Response Model POJO class::
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ResponseModel implements Serializable{
String success;
List errors;
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
public List getErrors() {
return errors;
}
public void setErrors(List errors) {
this.errors = errors;
}
public List getWarnings() {
return warnings;
}
public void setWarnings(List warnings) {
this.warnings = warnings;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
List warnings;
Object data;
String transactionId;
public String getTransactionId() {
return transactionId;
}
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}