dev@jersey.java.net

[Jersey] jersey-json _at_Consume POST

From: Gallagher,Patrick <Patrick.Gallagher_at_Cerner.com>
Date: Fri, 23 Oct 2009 16:11:29 -0500

Thanks Jakub for the files. Sorry about the typos in the XSD. For my benefit, was the error you spoke about the missing / after the name element? After looking through your project, I noticed that this was built with 1.1.5-ea-SNAPSHOT. I should have mentioned that I was using the general release version 1.0.3. The other change that really alters the execution is changing from your POST implementation to my POST implementation below. This breaks when I downgrade to 1.0.3 but works fine in 1.1.5-ea-SNAPSHOT, and even 1.1.3-ea.


Your POST

@POST

    @Consumes("application/json")

    @Produces("application/json")

    public JAXBElement<ReqType> postIt(JAXBElement<ReqType> it) {

        it.getValue().name = "updated";

        return it;

    }

 

My POST

@POST

    @Consumes( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })

    @Produces(MediaType.APPLICATION_JSON)

    public CreateArtifactRequest postIt(CreateArtifactRequest it) {

        it.name = "updated";

        return it;

    }

 

This does require us to change the XSD back to my original format, with the appropriate tag with a closing "/" in the name element.

 

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:example="http://www.example.com"

      targetNamespace="http://www.example.com">

      <element name="create_artifact_request">

            <complexType>

                  <sequence>

                        <element name="name" type="string" />

                        <element name="version" type="string" />

                        <element name="release_ind" type="boolean" />

                        <element name="repository_id" type="int" />

                        <element name="repository_path" type="string" />

                        <element name="group_id" type="int" />

                        <element name="scmr_id" type="int" />

                        <element name="scmr_revision" type="string" minOccurs="0" />

                        <element name="scmr_path" type="string" minOccurs="0" />

                        <element name="team_number" type="int" />

                        <element name="sub_type" type="string" />

                  </sequence>

            </complexType>

      </element>

</schema>

 

In short, I think upgrading to 1.1.3-ea will fix my problems although I'm not sure why accepting CreateArtifactRequest instead of JAXBElement<ReqType> in my function signature changes the behavior so drastically.

 

Thanks for your help, I appreciate it.

 

Patrick G

 

----------------------------------------------------------------------
CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.