cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: REST/JSON webservice & messages with variable number of fields
Date Mon, 17 Feb 2014 15:52:19 GMT
Hi
On 17/02/14 14:59, Jose MarĂ­a Zaragoza wrote:
> Hello:
>
> I'm using CXF 2.7.8
>
> I need to develope a REST webservice. This webservice will receive by
> POST , in a fixed URL/endpoint ( http://mywebservice/notify) , a lot
> of messages in JSON format
>
> For example
>
> { "status":"1", "client":"Amy" }
> { "status":"2", "agent":"00034", "city":"London" }
> ...
> { "status":"123", "color":"red" }
>
> Note:
> I cannot define another URL ( for example,
> http://mywebservice/notify/{status}  )
>
> Although the webservice can receive a lot of messages , it only must
> perform some action with some of them, based on "status" field
> For example, status 2, 5, 17. In other case, it only must log the
> message received ( for example, "Status 123 received" )
>
> I'm doing the webservice choosing Jettison as JSON provider, so I need
> to have a class with JAXB annotations, so map the message to an object
>
> If, in the future, a new message with a new status is sent ( {
> "status":"124", "size":"20px" } ) , I don't want to have to compile my
> JAXB classes again to map this new message
>
> I would like:
>
> - the non-relevant messages ( others than status is 2, 5, 17 ) map to
> a fixed format , for example, { "status":"xxxx" }
> So, if I receive  { "status":"124", "size":"20px" } ,  map it to  {
> "status":"124" }
>
> How I can do this ?
>
So you basically would like the unrecognized 'size' property be ignored 
? JAXB, without a schema, may let you do it as is, and in addition to 
that you should be able to use 'inDropElements' property. You can alsoi 
register a custom XMLStreamReader if needed, customizing it even further

Does it answer your question ?

Cheers, Sergey


> or
>
> - any ideas ?
>
> Thanks and regards
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message