我不熟悉Web服务,因此创建了一个演示Web服务。我正在使用邮递员检查服务,并收到415错误。我的邮递员头中确实有内容类型的application / json。仍然有问题。请帮忙。
@Path("/orderTracking")
public class OrderRestService {
@POST
@Path("/track")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response getOrderStatus(ServiceRequest request) {
ServiceResponse serviceResponse = new ServiceResponse();
ResponseData responseData = new ResponseData();
if(request.getRequest().getOrderId() != null) {
responseData.setOrderId(request.getRequest().getOrderId());
responseData.setOrderStatus("Order is confirmed");
responseData.setOrderDate("25/10/2018");
responseData.setCustomerName("xxx");
responseData.setCustomerAddress("yyyyyyyyyy");
responseData.setDeliveryDate("01/11/2018");
}else {
responseData.setOrderStatus("Order Failed");
System.out.println("Error in Service");
}
serviceResponse.setResponse(responseData);
return Response.status(200).entity(serviceResponse).build();