Hi,
i presume you want to exchange XML entities. Then you need
to annotate your resource methods with
@Produces("application/xml") and/or @Consumes("application/xml")
according to what your resource method does (producing and/or consuming
JAXB beans).
You also need to make sure appropriate HTTP headers are used on the
client side,
namely Content-type and also Accept header should be used there to determine
the media type for the entities.
A complete example (including tests with client side code) could be
downloaded from [1].
HTH,
~Jakub
[1]
http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/jaxb/1.10-b05/jaxb-1.10-b05-project.zip
On 24.10.2011 6:07, tyo07 wrote:
> Hello, i'm trying to consume web service using jersey. Server was made from
> spring and it's REST based. When using java restclient i'm able to retrieve
> data from the temporary database that i added manually. But when i'm using
> Junit to test whether the server can response my request or not, "The
> registered message body readers compatible with the MIME media type are" are
> showed up.
>
> Details : A message body reader for Java class
> com.hascode.tutorial.rest.bean.CustomerBean, and Java type class
> com.hascode.tutorial.rest.bean.CustomerBean, and MIME media type
> application/octet-stream was not found.
>
> file customerbean itself was like this.
>
> [CODE]
> package com.hascode.tutorial.rest.bean;
>
> import javax.ws.rs.*;
>
> import javax.xml.bind.annotation.XmlAttribute;
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement(name = "customer")
> @Consumes({"application/xml", "application/json"})
>
> public class CustomerBean {
> private Long id;
> private String firstName;
> private String lastName;
> private Double money;
>
> @XmlAttribute
>
> public Long getId() {
> return id;
> }
> public void setId(Long id) {
> this.id = id;
> }
> public String getfirstName() {
> return firstName;
> }
> public void setfirstName(String firstName) {
> this.firstName = firstName;
> }
>
> @XmlElement(name = "customer_lastName")
> public String getlastName() {
> return lastName;
> }
> public void setlastName(String lastName) {
> this.lastName = lastName;
> }
> public Double getmoney() {
> return money;
> }
> public void setmoney(Double money) {
> this.money = money;
> }
> }[/CODE]
>
> I might be wrong at using @Consumes/_at_Produces, but where should i set that
> type so "application octet stream" error not showed up?
>
> Sorry for bad english:D
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/The-registered-message-body-readers-compatible-with-the-MIME-media-type-are-tp6923901p6923901.html
> Sent from the Jersey mailing list archive at Nabble.com.
>