On Thu, Nov 19, 2009 at 3:10 AM, John Klassa <[email protected]> wrote:

>
> Hi Sergey,
>
> I found some other sample XML on the web, and it appears to amount to this:
>
>  <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>    <property name="marshallerProperties">
>       <map>
>         <entry key="jaxb.formatted.output">
>           <value type="java.lang.Boolean">true</value>
>        </entry>
>      </map>
>    </property>
>  </bean>
>
> Yet, even this doesn't work (nor does "TRUE").  The XML still comes back
> without whitespace, when I make a REST call, and with no particular
> formatting.
>
> I know it's at least looking at this value because when I try to, e.g.,
> change it to "marshallerPropertiesx" (to put a typo in it), it complains,
> and suggests "marshallerProperties" for me.  So, I think the setting is
> fine.  Somehow, CXF and JAXB just aren't connecting the dots.
>
> I'm using a Spring-based approach now, to my knowledge.  My web.xml says:
>
>  <context-param>
>    <param-name>contextConfigLocation</param-name>
>    <param-value>WEB-INF/beans.xml</param-value>
>  </context-param>
>
>  <listener>
>    <listener-class>
>      org.springframework.web.context.ContextLoaderListener
>    </listener-class>
>  </listener>
>
>  <servlet>
>    <servlet-name>CDETSWSAPI</servlet-name>
>    <display-name>CDETS Web Services API</display-name>
>    <servlet-class>
>      org.apache.cxf.transport.servlet.CXFServlet
>    </servlet-class>
>    <load-on-startup>1</load-on-startup>
>  </servlet>
>
>  <servlet-mapping>
>    <servlet-name>CDETSWSAPI</servlet-name>
>    <url-pattern>/v1/*</url-pattern>
>  </servlet-mapping>
>
> while my beans.xml says:
>
>  <bean id="defectResourceBean"
> class="com.cisco.cdets.wsapi.resources.DefectResource"/>
>
>  <jaxrs:server id="defectResource" address="/">
>    <jaxrs:serviceBeans>
>      <ref bean="defectResourceBean"/>
>    </jaxrs:serviceBeans>
>  </jaxrs:server>
>
>  <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>    <property name="marshallerProperties">
>       <map>
>         <entry key="jaxb.formatted.output">
>           <value type="java.lang.Boolean">true</value>
>        </entry>
>      </map>
>    </property>
>  </bean>
>
> Any ideas?
>
> Thanks!
>
> On Nov 18, 2009, at 3:36 PM, Sergey Beryozkin wrote:
>
> > Hi
> >
> > I'm sorry, that property has to be of type java.lang.Boolean according
> > to the Marshaller docs. I'm not sure right now how to specify from
> > Spring that a given map value should be of Boolean type, does anyone
> > know how to do it ?
> > I'll give it a try tomorrow
> >
> > Thanks, Sergey
> >
> >
> >
> > -----Original Message-----
> > From: John Klassa [mailto:[email protected]]
> > Sent: 18 November 2009 18:39
> > To: [email protected]
> > Subject: Re: pretty printing XML
> >
> >
> > Sorry...  I meant to say that the primary docs (for JAX-RS in CXF) is
> > where I got the same XML from.  It doesn't work for me, though.  So, I
> > went looking online, and found the osdir.com reference to doing it
> > programmatically.
> >
> > Regardless, just looking to get it to work via a configuration setting.
> > :-)
> >
> > On Nov 18, 2009, at 1:35 PM, John Klassa wrote:
> >
> >>
> >> Saw this thread:
> >>
> >> http://osdir.com/ml/users-cxf-apache/2009-09/msg00014.html
> >>
> >> but am wondering how this would be done in a config file.  I saw an
> > example somewhere that says to use:
> >>
> >> <bean id="jaxbProvider"
> > class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
> >>   <property name="marshallerProperties" ref="propertiesMap"/>
> >> </bean>
> >> <util:map id="propertiesMap" map-class="java.util.Hashtable">
> >>   <entry key="jaxb.formatted.output" value="true"/>
> >> </util:map>
> >>
> >> This seems to have no effect, however.
> >>
> >> Basically, I'm trying to get my JAX-RS resources to come back looking
> > "nice".
> >>
> >
>
>
This sounds good. Does it only work if you use jaxb?

M.
-- 
I keep six honest serving-men (They taught me all I knew); Their names are
What and Why and When And How and Where and Who.

Reply via email to