Hi there,

even adding the MediaType to annotations does not help.
Either there is a problem with my JSON Provider (Jackson) or something wrong 
with Wink.

As a workaround I now added an EntiyProvider-Reader to my implementation which 
will create the asset.
So I now user my own Reader to create the asset.
The assets @Produces method will created the object being sent to the client.


Regards
Stefan


From: Luciano Resende [mailto:[email protected]]
Sent: Freitag, 27. Juli 2012 18:45
To: [email protected]
Subject: Re: Problems consuming JSON request with an Aseet


On Thu, Jul 26, 2012 at 6:26 AM, Meyer, Stefan 
<[email protected]<mailto:[email protected]>> wrote:
Hi together,

My current problem is that my asset is not able to consume “application/json” 
requests.
Other content-types are working (e.g. application/xml, text/plain etc.)

When consuming a http-request with content-type json my code does not jump in 
the method
AssetCreator-> createAsset()

If I change the content-type to any other than json, everythings works fine
Any idea what I am doing wrong?

Below my two classes:

Resource-Class:
@Path("vfs")
public class VFSResource {
/**
      * Creates an Asset
      *
       * @return
      */
      @POST
      @Produces(MediaType.APPLICATION_JSON)
      @Consumes(MediaType.APPLICATIN_JSON)
      public AssetCreator createAsset(AssetCreator assetCreator) {
            return assetCreator;
      }
}

My Asset:
@Asset
public class AssetCreator {

      private Doctype doctype;

      public AssetCreator() {
      }

      @Consumes
      public void createAsset(Doctype doctype) {
            System.out.println("consume");
            this.doctype = doctype;
      }

      @Produces
      public Doctype getDocType() {
            return new Doctype();
      }
}



I haven't had a chance to actually investigate this yet, but you could try to 
specify the media type on the asset annotations.

--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/
IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Michael Rehm, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - 
Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.ids-scheer-consulting.com

Reply via email to