Hi,

On Tue, Jul 12, 2011 at 5:08 PM, Christian Hartmann
<[email protected]> wrote:
> Hi there,
>
> I am using Apache CXF 2.4.1 and I want to POST a JSON-String to my 
> RestFul-Service.
>
> So I configure the following within my Spring 3.x configuration:
>
>    <util:map id="nstojns" map-class="java.util.HashMap">
>        <entry key="http://xyz.com/serviceapi"; value="serviceapi"/>
>    </util:map>
>
>    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
>        <property name="namespaceMap" ref="nstojns"/>
>        <property name="ignoreNamespaces" value="true"/>
>        <property name="inTransformElements">
>            <map>
>                <entry key="FeedbackData" 
> value="{http://xyz.com/serviceapi}FeedbackData"/>
>                <entry key="FeedbackEvent" 
> value="{http://xyz.com/serviceapi}FeedbackEvent"/>
>            </map>
>        </property>
>    </bean>
>
>     <jaxrs:server id="cxfService" 
> address="${cxf.endpoint.shopservice.address}">
>        <jaxrs:serviceFactories>
>            <ref bean="feedbackFacadeFactory"/>
>        </jaxrs:serviceFactories>
>        <jaxrs:providers>
>            <ref bean="jsonProvider"/>
>        </jaxrs:providers>
>     </jaxrs:server>
>
> Now I can call my service and do a POST sending a JSON-Object like this:
>
> {"FeedbackData":{"FeedbackEvent":{"@accessProfile":"Test"}}}
>
> and the binding is done by JAXB based on a provided XSD without any problems.
>
> However I have to mention the ugly "@" for my attributes. Is there any way to 
> configure CXF and/or the JSONProvider not to have to use the "@" as a marker 
> for the attribute? If yes, how?
>

Try adding

<property name="attributesToElements" value="true"/>

that should do it

Cheers, Sergey

> Any help will be appreciated.
>
> Regards,
>
> Christian
>
>
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com

Reply via email to