dev@jersey.java.net

RE: [Jersey] jersey-json _at_Consume POST

From: Gallagher,Patrick <Patrick.Gallagher_at_Cerner.com>
Date: Mon, 26 Oct 2009 08:58:55 -0500

CreateArtifactRequest is annotated with both the @XmlRootElement and @XmlType. Here is the definition, which is created by the org.jvnet.jaxb2.maven2:maven2-jaxb2-plugin.

 

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

    "name",

    "version",

    "releaseInd",

    "repositoryId",

    "repositoryPath",

    "groupId",

    "scmrId",

    "scmrRevision",

    "scmrPath",

    "teamNumber",

    "subType"

})

@XmlRootElement(name = "create_artifact_request", namespace = "http://www.example.com")

public class CreateArtifactRequest

    implements Serializable

 

Thanks,

 

Patrick

 

________________________________



Content-type: text/plain; delsp=yes; format=flowed; charset=WINDOWS-1252
Date: Mon, 26 Oct 2009 09:42:00 +0100
From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Subject: [Jersey] jersey-json @Consume POST
 
On Oct 23, 2009, at 11:11 PM, Gallagher,Patrick wrote:
> 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.
>
 
Is CreateArtifactRequest annotated with @XmlRootElement or @XmlType?
 
If the latter it might be a bug in 1.0.3.
 
Paul.
 
 
 

 

From: Gallagher,Patrick
Sent: Friday, October 23, 2009 4:11 PM
To: 'dev_at_jersey.dev.java.net'
Subject: [Jersey] jersey-json @Consume POST

 

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.