Java org.jboss.resteasy.spi.BadRequestException:内容类型:application/json

Java org.jboss.resteasy.spi.BadRequestException:内容类型:application/json,java,rest,api,Java,Rest,Api,这是我的模型: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.dwidasa.kse.ksei.model; /** * * @author as

这是我的模型:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dwidasa.kse.ksei.model;

/**
 *
 * @author asus
 */
public class ParticipantMsg {


    private String participantCode;
    private String ktpNumber;
    private String namaLengkap;
    private String tanggalLahir;
    private String jenisKelamin;
    private String noRekeningInvestor;
    private String nationality;
    private String tipeInvestor;
    private String reason;

    public String getParticipantCode() {
        return participantCode;
    }

    public void setParticipantCode(String participantCode) {
        this.participantCode = participantCode;
    }

    public String getKtpNumber() {
        return ktpNumber;
    }

    public void setKtpNumber(String ktpNumber) {
        this.ktpNumber = ktpNumber;
    }

    public String getNamaLengkap() {
        return namaLengkap;
    }

    public void setNamaLengkap(String namaLengkap) {
        this.namaLengkap = namaLengkap;
    }

    public String getTanggalLahir() {
        return tanggalLahir;
    }

    public void setTanggalLahir(String tanggalLahir) {
        this.tanggalLahir = tanggalLahir;
    }

    public String getJenisKelamin() {
        return jenisKelamin;
    }

    public void setJenisKelamin(String jenisKelamin) {
        this.jenisKelamin = jenisKelamin;
    }

    public String getNoRekeningInvestor() {
        return noRekeningInvestor;
    }

    public void setNoRekeningInvestor(String noRekeningInvestor) {
        this.noRekeningInvestor = noRekeningInvestor;
    }

    public String getNationality() {
        return nationality;
    }

    public void setNationality(String nationality) {
        this.nationality = nationality;
    }

    public String getTipeInvestor() {
        return tipeInvestor;
    }

    public void setTipeInvestor(String tipeInvestor) {
        this.tipeInvestor = tipeInvestor;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

}
这是我的服务器代码:

package com.dwidasa.ib.services;

import com.dwidasa.engine.json.PojoJsonMapper;
import com.dwidasa.ib.annotations.NoValidate;
import com.dwidasa.kse.ksei.model.ParticipantMsg;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import org.jboss.resteasy.annotations.cache.NoCache;
import org.springframework.web.bind.annotation.RequestBody;

@Path("/dukcapil")
@NoCache
public abstract interface KSEIDukcapilResource
{
    @NoValidate
    @POST
    @Produces({"application/json;charset=utf-8"})
    @Consumes("application/json")
    @Path("inquiryKSEI")
    public abstract String inquiryNIK(@Context HttpServletRequest paramHttpServletRequest, 
                @RequestBody ParticipantMsg msg);
  }
以下是我的messagebodyreader代码:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dwidasa.kse.ksei.service;

import com.dwidasa.kse.ksei.model.ParticipantMsg;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.io.*;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;


/**
 *
 * @author asus
 */
@Provider
@Consumes("application/json")
public class ParticipantBodyReader implements MessageBodyReader<ParticipantMsg> {
    @Override
    public boolean isReadable(Class<?> type, Type genericType,
                              Annotation[] annotations, MediaType mediaType) {
        return type == ParticipantMsg.class;
    }

    @Override
    public ParticipantMsg readFrom(Class<ParticipantMsg> type, Type genericType, Annotation[] annotations,
                         MediaType mediaType, MultivaluedMap<String, String> httpHeaders,
                         InputStream entityStream) throws IOException, WebApplicationException {

        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(ParticipantMsg.class);
            return (ParticipantMsg) jaxbContext.createUnmarshaller().unmarshal(entityStream);
        } catch (JAXBException e) {
//            throw new ProcessingException("Error deserializing user.", e);
            throw new WebApplicationException(e);
        }
    }

}
/*
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择工具|模板
*然后在编辑器中打开模板。
*/
包com.dwidasa.kse.ksei.service;
导入com.dwidasa.kse.ksei.model.ParticipantMsg;
导入javax.ws.rs.Consumes;
导入javax.ws.rs.WebApplicationException;
导入javax.ws.rs.core.MediaType;
导入javax.ws.rs.core.MultivaluedMap;
导入javax.ws.rs.ext.MessageBodyReader;
导入javax.ws.rs.ext.Provider;
导入javax.xml.bind.JAXBContext;
导入javax.xml.bind.JAXBException;
导入java.io.*;
导入java.lang.annotation.annotation;
导入java.lang.reflect.Type;
/**
*
*@作者华硕
*/
@提供者
@使用(“应用程序/json”)
公共类ParticipantBodyReader实现MessageBodyReader{
@凌驾
公共布尔值可读取(类类型、类型genericType、,
注释[]注释,MediaType(MediaType){
返回类型==ParticipantMsg.class;
}
@凌驾
public ParticipantMsg readFrom(类类型、类型genericType、注释[]注释、,
MediaType MediaType,多值映射HttpHeader,
InputStream entityStream)引发IOException、WebApplicationException{
试一试{
JAXBContext JAXBContext=JAXBContext.newInstance(ParticipantMsg.class);
return(ParticipantMsg)jaxbContext.createUnmarshaller().unmarshal(entityStream);
}捕获(JAXBEException e){
//抛出新的ProcessingException(“反序列化用户时出错。”,e);
抛出新的WebApplicationException(e);
}
}
}
我使用RESTAPI作为服务器,但当我从邮递员那里得到消息时,总是出现get错误。 “org.jboss.resteasy.spi.BadRequestException:找不到内容类型为application/json的com.dwidasa.kse.ksei.model.ParticipantMsg类型的邮件正文读取器”