You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John Klassa <jo...@klassa.com> on 2009/11/18 19:35:02 UTC
pretty printing XML
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".
Re: interceptors - message
Posted by Ernst Oberortner <e....@infosys.tuwien.ac.at>.
hi gabo...
many thanks for your help...
this was the solution to my problem...
cheers,
ernst
> Hi Ernst,
>
> I do not think that is how Exchange works. My suggestion is for your
> client's out interceptor to place those values as header parameters.
> Then your server in interceptor to catch those headers and place it
> in the message's exchange.
>
> Hth.
>
> Gabo
>
> Ernst Oberortner wrote:
>> i'm sorry... i tried it... but it's still not working...
>>
>> here are some excerpts of my source-code...
>>
>> on the client side, i put the following interceptor into every
>> phase of the CLIENT's OUT chain...
>> public class ClientOutInterceptor extends
>> AbstractPhaseInterceptor<Message> {
>> ...
>> public void handleMessage(Message msg) throws Fault {
>> msg.getExchange().put("ABC",new String("ABC"));
>> msg.getExchange().getOutMessage().put("ABC",new
>> String("ABC"));
>> }
>> ...
>> }
>>
>> at the service host, i put the following interceptor into every
>> phase of the SERVER's IN chain...
>> public class ServerInInterceptor extends
>> AbstractPhaseInterceptor<Message> {
>> ...
>> public void handleMessage(Message msg) throws Fault {
>> if(msg.getExchange().getInMessage().get("ABC")==null) {
>> System.out.println("ABC not present in IN message");
>> }
>> if(msg.getExchange().get("ABC")==null) {
>> System.out.println("ABC not present in exchange message");
>> }
>> }
>> ...
>> }
>>
>> but, the server's interceptors always say...
>> ABC not present in IN message
>> ABC not present in exchange message
>>
>> what am i doing wrong? any hints please?
>> thx!
>>
>> cheers,
>> ernst
>>
>>>
>>> The message object holds onto the exchange which holds onto both
>>> the in and
>>> out messages. Thus, on the in chain, you can do
>>> msg.getExchange().getInMessage().get(...);
>>>
>>> Alternatively, the Exchange also implements Map. Thus, store it
>>> on the
>>> Exchange itself.
>>>
>>> Dan
>>>
>>>
>>> On Thu November 19 2009 9:11:10 am Ernst Oberortner wrote:
>>>> dear all!
>>>>
>>>> i have a question regarding the data of the message which is
>>>> transfered
>>>> from the client to the service...
>>>>
>>>> example:
>>>> i have an interceptor in the client out-chain (doesn't matter yet
>>>> in
>>>> which phase) which puts some data into the message
>>>> (by using the Message.put method)... now i want to read the data
>>>> in the
>>>> in-chain of the service host...
>>>>
>>>> i haven't discovered yet any possibility how to implement this...
>>>>
>>>> so please... can anybody help me by giving hints, examples, or
>>>> links?
>>>>
>>>> many thanks in advance!
>>>>
>>>> best regards,
>>>> ernst
>>>>
>>>
>>> --
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>
>>
Re: interceptors - message
Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Ernst,
I do not think that is how Exchange works. My suggestion is for your
client's out interceptor to place those values as header parameters.
Then your server in interceptor to catch those headers and place it in
the message's exchange.
Hth.
Gabo
Ernst Oberortner wrote:
> i'm sorry... i tried it... but it's still not working...
>
> here are some excerpts of my source-code...
>
> on the client side, i put the following interceptor into every phase
> of the CLIENT's OUT chain...
> public class ClientOutInterceptor extends
> AbstractPhaseInterceptor<Message> {
> ...
> public void handleMessage(Message msg) throws Fault {
> msg.getExchange().put("ABC",new String("ABC"));
> msg.getExchange().getOutMessage().put("ABC",new String("ABC"));
> }
> ...
> }
>
> at the service host, i put the following interceptor into every phase
> of the SERVER's IN chain...
> public class ServerInInterceptor extends
> AbstractPhaseInterceptor<Message> {
> ...
> public void handleMessage(Message msg) throws Fault {
> if(msg.getExchange().getInMessage().get("ABC")==null) {
> System.out.println("ABC not present in IN message");
> }
> if(msg.getExchange().get("ABC")==null) {
> System.out.println("ABC not present in exchange message");
> }
> }
> ...
> }
>
> but, the server's interceptors always say...
> ABC not present in IN message
> ABC not present in exchange message
>
> what am i doing wrong? any hints please?
> thx!
>
> cheers,
> ernst
>
>>
>> The message object holds onto the exchange which holds onto both the
>> in and
>> out messages. Thus, on the in chain, you can do
>> msg.getExchange().getInMessage().get(...);
>>
>> Alternatively, the Exchange also implements Map. Thus, store it on the
>> Exchange itself.
>>
>> Dan
>>
>>
>> On Thu November 19 2009 9:11:10 am Ernst Oberortner wrote:
>>> dear all!
>>>
>>> i have a question regarding the data of the message which is transfered
>>> from the client to the service...
>>>
>>> example:
>>> i have an interceptor in the client out-chain (doesn't matter yet in
>>> which phase) which puts some data into the message
>>> (by using the Message.put method)... now i want to read the data in the
>>> in-chain of the service host...
>>>
>>> i haven't discovered yet any possibility how to implement this...
>>>
>>> so please... can anybody help me by giving hints, examples, or links?
>>>
>>> many thanks in advance!
>>>
>>> best regards,
>>> ernst
>>>
>>
>> --
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>
>
Re: interceptors - message
Posted by Ernst Oberortner <e....@infosys.tuwien.ac.at>.
i'm sorry... i tried it... but it's still not working...
here are some excerpts of my source-code...
on the client side, i put the following interceptor into every phase
of the CLIENT's OUT chain...
public class ClientOutInterceptor extends
AbstractPhaseInterceptor<Message> {
...
public void handleMessage(Message msg) throws Fault {
msg.getExchange().put("ABC",new String("ABC"));
msg.getExchange().getOutMessage().put("ABC",new String("ABC"));
}
...
}
at the service host, i put the following interceptor into every phase
of the SERVER's IN chain...
public class ServerInInterceptor extends
AbstractPhaseInterceptor<Message> {
...
public void handleMessage(Message msg) throws Fault {
if(msg.getExchange().getInMessage().get("ABC")==null) {
System.out.println("ABC not present in IN message");
}
if(msg.getExchange().get("ABC")==null) {
System.out.println("ABC not present in exchange message");
}
}
...
}
but, the server's interceptors always say...
ABC not present in IN message
ABC not present in exchange message
what am i doing wrong? any hints please?
thx!
cheers,
ernst
>
> The message object holds onto the exchange which holds onto both the
> in and
> out messages. Thus, on the in chain, you can do
> msg.getExchange().getInMessage().get(...);
>
> Alternatively, the Exchange also implements Map. Thus, store it on
> the
> Exchange itself.
>
> Dan
>
>
> On Thu November 19 2009 9:11:10 am Ernst Oberortner wrote:
>> dear all!
>>
>> i have a question regarding the data of the message which is
>> transfered
>> from the client to the service...
>>
>> example:
>> i have an interceptor in the client out-chain (doesn't matter yet in
>> which phase) which puts some data into the message
>> (by using the Message.put method)... now i want to read the data in
>> the
>> in-chain of the service host...
>>
>> i haven't discovered yet any possibility how to implement this...
>>
>> so please... can anybody help me by giving hints, examples, or links?
>>
>> many thanks in advance!
>>
>> best regards,
>> ernst
>>
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
Re: interceptors - message
Posted by Daniel Kulp <dk...@apache.org>.
The message object holds onto the exchange which holds onto both the in and
out messages. Thus, on the in chain, you can do
msg.getExchange().getInMessage().get(...);
Alternatively, the Exchange also implements Map. Thus, store it on the
Exchange itself.
Dan
On Thu November 19 2009 9:11:10 am Ernst Oberortner wrote:
> dear all!
>
> i have a question regarding the data of the message which is transfered
> from the client to the service...
>
> example:
> i have an interceptor in the client out-chain (doesn't matter yet in
> which phase) which puts some data into the message
> (by using the Message.put method)... now i want to read the data in the
> in-chain of the service host...
>
> i haven't discovered yet any possibility how to implement this...
>
> so please... can anybody help me by giving hints, examples, or links?
>
> many thanks in advance!
>
> best regards,
> ernst
>
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
interceptors - message
Posted by Ernst Oberortner <e....@infosys.tuwien.ac.at>.
dear all!
i have a question regarding the data of the message which is transfered
from the client to the service...
example:
i have an interceptor in the client out-chain (doesn't matter yet in
which phase) which puts some data into the message
(by using the Message.put method)... now i want to read the data in the
in-chain of the service host...
i haven't discovered yet any possibility how to implement this...
so please... can anybody help me by giving hints, examples, or links?
many thanks in advance!
best regards,
ernst
--
-----------------------------------------------------------------
Ernst Oberortner
Distributed Systems Group (DSG), Information Systems Institute
Vienna University of Technology, Austria
A-1040 Wien, Argentinierstrasse 8/184-1
Tel +43-1-58801-58413
Fax +43-1-58801-18491
URL: http://www.infosys.tuwien.ac.at/Staff/ernstl/
-----------------------------------------------------------------
Re: pretty printing XML
Posted by John Klassa <jo...@klassa.com>.
Excellent -- that did it!
Thank you!
On Nov 19, 2009, at 4:43 AM, Sergey Beryozkin wrote:
> Hi John
>
> You're nearly there, please do
>
> <jaxrs:server id="defectResource" address="/">
> <jaxrs:serviceBeans>
> <ref bean="defectResourceBean"/>
> </jaxrs:serviceBeans>
> <jaxrs:providers>
> <ref bean="jaxbProvider"/>
> </jaxrs:providers>
> </jaxrs:server>
> <jaxrs:server>
>
> This way you can associate multiple JAXB providers with slightly different settings with multiple endpoints in the same context....
>
> I'm sorry yourself and some other users are havig some hard time in seeing the simple apps up and running. I think CXF JAXRS docs have plenty of info but a GettingStarted guide and FAQ are needed urgently...
>
> thanks, Sergey
>
> ----- Original Message ----- From: "John Klassa" <jo...@klassa.com>
> To: <us...@cxf.apache.org>
> Sent: Thursday, November 19, 2009 1:10 AM
> Subject: Re: pretty printing XML
>
>
>
> 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:klassa@cisco.com]
>> Sent: 18 November 2009 18:39
>> To: users@cxf.apache.org
>> 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".
>>>
>>
>
Re: pretty printing XML
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi John
You're nearly there, please do
<jaxrs:server id="defectResource" address="/">
<jaxrs:serviceBeans>
<ref bean="defectResourceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jaxbProvider"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server>
This way you can associate multiple JAXB providers with slightly different settings with multiple endpoints in the same context....
I'm sorry yourself and some other users are havig some hard time in seeing the simple apps up and running. I think CXF JAXRS docs
have plenty of info but a GettingStarted guide and FAQ are needed urgently...
thanks, Sergey
----- Original Message -----
From: "John Klassa" <jo...@klassa.com>
To: <us...@cxf.apache.org>
Sent: Thursday, November 19, 2009 1:10 AM
Subject: Re: pretty printing XML
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:klassa@cisco.com]
> Sent: 18 November 2009 18:39
> To: users@cxf.apache.org
> 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".
>>
>
Re: pretty printing XML - AtomFeedProvider
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Paul
Good idea, will do
thanks, Sergey
----- Original Message -----
From: "Paul Wilton" <Pa...@bbc.com>
To: <us...@cxf.apache.org>
Sent: Thursday, November 19, 2009 1:58 PM
Subject: RE: pretty printing XML - AtomFeedProvider
Hi Sergey
Any chance you could expose a method on the AtomFeedProvider and
AtomEntryProvider to turn on/off pretty printing of the ATOM generated
by these providers.
The underlying Abdera ATOM writers have a configuration option to pretty
print:
See:
http://cwiki.apache.org/ABDERA/custom-writers.html
thanks
Paul
bbc.co.uk
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com]
Sent: 19 November 2009 10:43
To: users@cxf.apache.org
Subject: Re: pretty printing XML
Hi
> >>
>> <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>
>>
<snip/>
>>
> This sounds good. Does it only work if you use jaxb?
>
Yes, only if JAXB is used...What databinding technology do you use ?
Note we have an XmlBeans jaxrs provider which was contributed
to CXF awhile back, but at the moment it does not accept any external
configuration, which would be easy to fix. Also, one can
delegate to the CXF XMLBeans DataBinding which can be used by JAXWS
services with the help of the DataBinding jaxrs provider
(similarly for SDO); not sure if Aegis supports pretty-printing...
cheers, Sergey
> 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.
>
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless
specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the
information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this
This e-mail has been sent by one of the following wholly-owned subsidiaries of the BBC:
BBC Worldwide Limited, Registration Number: 1420028 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
RE: pretty printing XML - AtomFeedProvider
Posted by Paul Wilton <Pa...@bbc.com>.
Hi Sergey
Any chance you could expose a method on the AtomFeedProvider and
AtomEntryProvider to turn on/off pretty printing of the ATOM generated
by these providers.
The underlying Abdera ATOM writers have a configuration option to pretty
print:
See:
http://cwiki.apache.org/ABDERA/custom-writers.html
thanks
Paul
bbc.co.uk
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com]
Sent: 19 November 2009 10:43
To: users@cxf.apache.org
Subject: Re: pretty printing XML
Hi
> >>
>> <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>
>>
<snip/>
>>
> This sounds good. Does it only work if you use jaxb?
>
Yes, only if JAXB is used...What databinding technology do you use ?
Note we have an XmlBeans jaxrs provider which was contributed
to CXF awhile back, but at the moment it does not accept any external
configuration, which would be easy to fix. Also, one can
delegate to the CXF XMLBeans DataBinding which can be used by JAXWS
services with the help of the DataBinding jaxrs provider
(similarly for SDO); not sure if Aegis supports pretty-printing...
cheers, Sergey
> 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.
>
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this
This e-mail has been sent by one of the following wholly-owned subsidiaries of the BBC:
BBC Worldwide Limited, Registration Number: 1420028 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World News Limited, Registration Number: 04514407 England, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
BBC World Distribution Limited, Registration Number: 04514408, Registered Address: BBC Media Centre, 201 Wood Lane, London, W12 7TQ
Re: pretty printing XML
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
> >>
>> <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>
>>
<snip/>
>>
> This sounds good. Does it only work if you use jaxb?
>
Yes, only if JAXB is used...What databinding technology do you use ? Note we have an XmlBeans jaxrs provider which was contributed
to CXF awhile back, but at the moment it does not accept any external configuration, which would be easy to fix. Also, one can
delegate to the CXF XMLBeans DataBinding which can be used by JAXWS services with the help of the DataBinding jaxrs provider
(similarly for SDO); not sure if Aegis supports pretty-printing...
cheers, Sergey
> 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.
>
Re: pretty printing XML
Posted by Monde Hans <mo...@gmail.com>.
On Thu, Nov 19, 2009 at 3:10 AM, John Klassa <jo...@klassa.com> 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:klassa@cisco.com]
> > Sent: 18 November 2009 18:39
> > To: users@cxf.apache.org
> > 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.
Re: pretty printing XML
Posted by John Klassa <jo...@klassa.com>.
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:klassa@cisco.com]
> Sent: 18 November 2009 18:39
> To: users@cxf.apache.org
> 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".
>>
>
RE: pretty printing XML
Posted by Sergey Beryozkin <sb...@progress.com>.
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:klassa@cisco.com]
Sent: 18 November 2009 18:39
To: users@cxf.apache.org
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".
>
Re: pretty printing XML
Posted by John Klassa <kl...@cisco.com>.
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".
>