In CXF (2.7.10)-restful services describes the RESTful WebService service, where data transfer is based on XML format. If you want to transfer data based on JSON format, @Produces ("Application/xml") is modified to @Produces ("Application/json").
Packagecom.huey.demo.ws;Importjava.util.List;ImportJavax.jws.WebService;ImportJavax.ws.rs.DELETE;ImportJavax.ws.rs.GET;ImportJavax.ws.rs.POST;ImportJavax.ws.rs.PUT;ImportJavax.ws.rs.Path;ImportJavax.ws.rs.PathParam;Importjavax.ws.rs.Produces;ImportJavax.ws.rs.core.MediaType;ImportCom.huey.demo.bean.Book;Importcom.huey.demo.bean.ResultMsg; @WebService Public InterfaceBookservice {@GET//Specify the request method@Path ("/BOOK/{ISBN}")//Specifies the URI of the resource@Produces ({Mediatype.application_json})//Specify the media type for request/response PublicBook GetBook (@PathParam ("ISBN") String ISBN); @GET @Path ("/books") @Produces ({Mediatype.application_json}) PublicList<book>Getbooks (); @POST @Path ("/book") @Produces ({Mediatype.application_json}) Publicresultmsg addbook (book book); @PUT @Path ("/BOOK/{ISBN}") @Produces ({Mediatype.application_json}) PublicResultmsg Updatebook (@PathParam ("ISBN") String ISBN, Book book); @DELETE @Path ("/BOOK/{ISBN}") @Produces ({Mediatype.application_json}) PublicResultmsg Deletebook (@PathParam ("ISBN") String ISBN);}
Test.
A
b
C
D
E
CXF (2.7.10)-RESTful Services, JSON support