You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by guanzhong <gu...@gmail.com> on 2013/04/02 12:23:58 UTC

JAXB interface 415 - Unsupported Media Type

Hi
I have a question
the Parameter and Response Type of  EndPoint is interface

public interface ProtoTypeBizService<I extends CustomerIF, R extends
CustomerIF> {

    @POST
    @Path("doSomething")
    @Produces(MediaType.APPLICATION_XML)
    @Consumes(MediaType.APPLICATION_XML)
    R doSomething(I customer);

}

and the Abstact Implement is
public abstract class AbstractProtoTypeService<I extends AbstractCustomer, R
extends AbstractCustomer> implements ProtoTypeBizService<I, R> {

    @Override
    public R doSomething(I customer) {
        return doSomeInternal(customer);
    }

    abstract protected R doSomeInternal(I customer);
}

and the Implement is

@Path("/ProtoTypeService")
public class ProtoTypeServiceImpl extends AbstractProtoTypeService<Customer,
Customer> {

    @Override
    protected Customer doSomeInternal(Customer customer) {
        return customer;
    }

}

when I send the request in WinkClient. I get a error message on server

The following error occurred during the invocation of the handlers chain:
WebApplicationException (415 - Unsupported Media Type) with message 'null'
while processing POST request sent to
http://localhost:8080/WinkServer/ProtoTypeService/doSomething

My setting is OK, I test it on Jersey and Apache CXF. they are all OK.


I want to ask that, Is there any possible to make this case runable in Wink.

Thanks. 






--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/JAXB-interface-415-Unsupported-Media-Type-tp7572669.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.

Re: JAXB interface 415 - Unsupported Media Type

Posted by guanzhong <gu...@gmail.com>.
For this case, I have found a solution.
I can add the @XmlRootElement to CustomerIF and AbstractCustomer class.
also, I need to add the @XmlRootElement to Customer class.

And make sure that JAXBContext can find the Customer class.

And now, Wink can work well. 



--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/JAXB-interface-415-Unsupported-Media-Type-tp7572669p7572676.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.

Re: JAXB interface 415 - Unsupported Media Type

Posted by Luciano Resende <lu...@gmail.com>.
On Wed, Apr 3, 2013 at 6:40 AM, guanzhong <gu...@gmail.com> wrote:

> I debug the source of wink -1.2.1
> I find that wink uses the
> JAXBElement unmarshal(XMLStreamReader reader, Class expectedType) to do the
> unmarshal.
> and for this reason, wink does some xmlRootElement,xmlType,xmlAdapter
> check.
>
> and cxf use the
> Object unmarshal(XMLEventReader xmleventreader)
> and cxf does not need the check, and JAXB can tell the Type from the xml
> content.
>
>
>
Thanks for the investigation, if you have a proposed patch, please attach
to a jira and I can help review and apply it.

We will probably be having a new 1.3.1 release soon.

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: JAXB interface 415 - Unsupported Media Type

Posted by guanzhong <gu...@gmail.com>.
I debug the source of wink -1.2.1
I find that wink uses the 
JAXBElement unmarshal(XMLStreamReader reader, Class expectedType) to do the
unmarshal.
and for this reason, wink does some xmlRootElement,xmlType,xmlAdapter check.

and cxf use the 
Object unmarshal(XMLEventReader xmleventreader)
and cxf does not need the check, and JAXB can tell the Type from the xml
content.









--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/JAXB-interface-415-Unsupported-Media-Type-tp7572669p7572673.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.

Re: JAXB interface 415 - Unsupported Media Type

Posted by guanzhong <gu...@gmail.com>.
I change my question to easier.
If the parameter type of endpoint is a interface or abstractClass.
How can I handle this case?



--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/JAXB-interface-415-Unsupported-Media-Type-tp7572669p7572672.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.