dev@jersey.java.net

Re: [Jersey] jersey-json _at_Consume POST

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Fri, 23 Oct 2009 14:36:41 +0200

Forgot to attach the zip...

~Jakub

On Fri, Oct 23, 2009 at 02:34:29PM +0200, Jakub Podlesak wrote:
>
> Hello,
>
> please see the attached zip file containing a simple project reproducing your test case.
> Since the xsd schema you provided was broken, i have updated it a bit.
> The MainTest class (in src/test dir) reproduces the scenario you described (GET and POST)
> and works fine.
>
> If mvn clean verify fails for you on the project, please
> send back information on your environment.
>
> Thanks,
>
> ~Jakub
>
> On Thu, Oct 22, 2009 at 03:08:56PM -0500, Gallagher,Patrick wrote:
> > Hello,
> >
> >
> >
> > I am having trouble using my Jaxb Object in a POST that consumes an application/json request. The Jaxb object is generated using the maven2-jaxb-plugin from a .XSD file. I am able to complete this operation using standard XML and even able to generate a response from a GET in JSON format but I am not able to POST JSON data to the service. I received "The request sent by the client was syntactically incorrect" when posting the following to the service:
> >
> >
> >
> > {"name":"junittest7","version":"1.0","release_ind":"true","repository_id":"0","repository_path":"/test","group_id":"264","scmr_id":"0","scmr_path":"test","team_number":"1","sub_type":"JAR"}
> >
> >
> >
> > This string is the same string that results from a GET on a simple service call for the object. Can you give any hints as to why this syntax is not parsed correctly by the JSON Marshaller in the jersey-json add-on? As I step through the code, I get a marshaller error just after the JSON token for the first ":" character but cannot really tell why.
> >
> >
> >
> > Here is the XSD that generate the Jaxb Object:
> >
> >
> >
> > <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> elementFormDefault="qualified" ...>
> >
> > <xs:element name="create_artifact_request">
> >
> > <xs:complexType>
> >
> > <xs:sequence>
> >
> > <xs:element name="name" type="xs:string">
> >
> > <xs:element name="version" type="xs:string" />
> >
> > <xs:element name="release_ind" type="xs:boolean" />
> >
> > <xs:element name="repository_id" type="xs:int" />
> >
> > <xs:element name="repository_path" type="xs:string" />
> >
> > <xs:element name="group_id" type="xs:int" />
> >
> > <xs:element name="scmr_id" type="xs:int />
> >
> > <xs:element name="scmr_revision" type="xs:string" minOccurs="0 /">
> >
> > <xs:element name="scmr_path" type="xs:string" minOccurs="0" />
> >
> > <xs:element name="team_number" type="xs:int" />
> >
> > <xs:element name="sub_type" type="xs:string" />
> >
> > </xs:sequence>
> >
> > </xs:complexType>
> >
> > </xs:schema>
> >
> >
> >
> >
> >
> > Thanks for any guidance you can provide.
> >
> > ----------------------------------------------------------------------
> > 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.
>
> --
> Jakub Podlešák
> Software Engineer at SUN Microsystems And CZJUG Co-Leader
> http://blogs.sun.com/japod
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>

-- 
Jakub Podlešák
Software Engineer at SUN Microsystems And CZJUG Co-Leader
http://blogs.sun.com/japod