Re: Accessing application/json message body of POST request

2014-03-17 Thread gelo1234
Sorry, my mail got cut in the middle.

So, you should place @Consumes annotation in REST Resource + all that
Spring config explained here:
https://cocoon.apache.org/3.0/reference/html-single/index.html#webapps.rest

AND

JSONProvider in spring config:
  
 package.to.class.Order   

This one is from Apache CXF but you can use any other (e.g. from Jersey).

Hope this helps.

Greetings,
Greg


2014-03-17 19:57 GMT+01:00 gelo1234 :

> Hi Bardo,
>
> Are you talking about REST in C3 (cocoon-rest dependency) ?
>
> Have you tried annotating REST Resource with:
>
> @Consumes(MediaType.APPLICATION_JSON)
>
> ?
>
> e.g.
>
> @Path("/orders")
> @Consumes(MediaType.APPLICATION_JSON)public class OrderRestResource { 
>[image: (2)]
>
> private Settings settings;
>
> private static Map orders = new HashMap();
>
> @POST
> public void createOrder(Order order) {
> orders.put(order.id, order);
> }
>
> }
>
>
>
>
>
> 2014-03-16 20:36 GMT+01:00 Bardo Nelgen <
> mailing.list.in...@bnnperformances.de>:
>
>
>> Hi all,
>>
>> has someone ever accessed the message body of a post request to cocoon
>> which uses application/json as its content type?
>>
>> The same request is being handled without issues if posted as
>> application/x-www-form-urlencoded.
>>
>> Though, as soon as the content type is changed to JSON, Cocoon appears to
>> skip parsing the message body.
>>
>> Unfortunately it's not me making these POST calls; which is why just
>> "switching it" is not an option.
>>
>> Is there some setting which can tell cocoon to simply continue parsing,
>> either regardless of a post's content type (which, of course might raise
>> security issues...) or explicitly for application/json ?
>>
>> Any suggestions are welcome.
>>
>> Regards,
>>
>> Bardo
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
>> For additional commands, e-mail: users-h...@cocoon.apache.org
>>
>>
>


Re: Accessing application/json message body of POST request

2014-03-17 Thread gelo1234
Hi Bardo,

Are you talking about REST in C3 (cocoon-rest dependency) ?

Have you tried annotating REST Resource with:

@Consumes(MediaType.APPLICATION_JSON)

?

e.g.

@Path("/orders")
@Consumes(MediaType.APPLICATION_JSON)public class OrderRestResource {
  [image: (2)]

private Settings settings;

private static Map orders = new HashMap();

@POST
public void createOrder(Order order) {
orders.put(order.id, order);
}

}





2014-03-16 20:36 GMT+01:00 Bardo Nelgen <
mailing.list.in...@bnnperformances.de>:

>
> Hi all,
>
> has someone ever accessed the message body of a post request to cocoon
> which uses application/json as its content type?
>
> The same request is being handled without issues if posted as
> application/x-www-form-urlencoded.
>
> Though, as soon as the content type is changed to JSON, Cocoon appears to
> skip parsing the message body.
>
> Unfortunately it's not me making these POST calls; which is why just
> "switching it" is not an option.
>
> Is there some setting which can tell cocoon to simply continue parsing,
> either regardless of a post's content type (which, of course might raise
> security issues...) or explicitly for application/json ?
>
> Any suggestions are welcome.
>
> Regards,
>
> Bardo
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
> For additional commands, e-mail: users-h...@cocoon.apache.org
>
>


Re: Accessing application/json message body of POST request

2014-03-17 Thread Bardo Nelgen


Hi Warrell,

thanks for the input.

Though our problem actually isn't *processing* the JSON, but initially 
getting it out of a POST request's application/json message body at all. 
If the JSON is postet wwwform-urlencoded and comes with common 
variable-value pairs, indeed a variety of options exists.


If, however, one cannot even destill the payload itself out of the 
request, the largest variety of processing options is not of much help.


What I get is more something like this


POST /serviceendpoint/ HTTP/1.1

Host: mydomain.com

Authorization: MyAuthKeyHere

Accept-Encoding: gzip, deflate

Content-Type: application/json   // this is the identified reason, why 
Cocoon stops processing before the message body


Accept-Language: en-us

Accept: */*

Content-Length: 80

Connection: keep-alive

User-Agent: proprietaryUA

{"jsonPayload":"verylongpayloadcontentcangohereifyoulike"}


Nonetheless, thanks for all of your suggestions; will get back to these 
lateron for sure...


Best,

Bardo



On 16.03.14 23.00 Uhr, warrell harries wrote:


Hi Bardo,

The simplest way that I have found to handle json posts is to use the 
text generator. Alternatively, you are free to write a json generator 
which would convert json to xml as this is the default data format of  
cocoon. I have been successfuly using cocoon to handle json (the 
contemporary data format of choice) for a few years now. Very recently 
I have been using cocoon as middleware between a datasource and Cube. 
This Node.js app front ends mongodb using json as the transport over 
http. Cocoon still rocks in this new world. Please get in touch if 
there is anything I can help with. Best regards Warrell


On 16 Mar 2014 19:37, "Bardo Nelgen" 
> wrote:



Hi all,

has someone ever accessed the message body of a post request to
cocoon which uses application/json as its content type?

The same request is being handled without issues if posted as
application/x-www-form-urlencoded.

Though, as soon as the content type is changed to JSON, Cocoon
appears to skip parsing the message body.

Unfortunately it's not me making these POST calls; which is why
just "switching it" is not an option.

Is there some setting which can tell cocoon to simply continue
parsing, either regardless of a post's content type (which, of
course might raise security issues...) or explicitly for
application/json ?

Any suggestions are welcome.

Regards,

Bardo


-
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org

For additional commands, e-mail: users-h...@cocoon.apache.org