Hi,

I ran the tests in JAXRSClientServerBookTest and took a look in BookServer configuration but didn't find any clue.
Here is my JAXB provider configuration.

<!-- JAXB Provider -->
<bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
<property name="marshallerProperties" ref="marshallerPropertiesMap"/>
</bean>

<util:map id="marshallerPropertiesMap">
<entry key="enableBuffering">
<value type="java.lang.Boolean">true</value>
</entry>
</util:map>

I'm using CXF 2.3.3.

Cheerssp,
Nikolay

On 10/21/2011 12:09 AM, Sergey Beryozkin wrote:
Hi

sorry for a delay,

I just run an existing test in JAXRSClientServerBookTest and I'm seeing:

Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Book><id>321</id></Book>

How do you configure JAXB provider ?

Cheers, Sergey

On 20/10/11 13:18, Nikolay Aleksiev wrote:
I am developing web services using Apache CXF and Spring. My interfaces
and configuration are configured so that I have both REST and SOAP
services. Apache CXF is not putting the XML document start: |<?xml
version="1.0" encoding="UTF-8"?>|

For the SOAP service I implemented an interceptor and it works
perfectly. Here's the code:

|public class CustomHeaderInterceptor extends
AbstractPhaseInterceptor<Message> {

public CustomHeaderInterceptor() {
super(Phase.PRE_STREAM);
addBefore(StaxOutInterceptor.class.getName());
}

@Override
public void handleMessage(Message message) throws Fault {
message.put(Message.ENCODING, "UTF-8");
message.put(StaxOutInterceptor.FORCE_START_DOCUMENT, Boolean.TRUE);
}
}
|

The interceptor is added with the following configuration:

|<bean id="customHeader"
class="com.minervanetworks.xtv.stb.utils.CustomHeaderInterceptor" />

<cxf:bus>
<cxf:inInterceptors>
<ref bean="logInbound" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="customHeader" />
<ref bean="logOutbound" />
</cxf:outInterceptors>
<cxf:inFaultInterceptors>
<ref bean="logInbound" />
</cxf:inFaultInterceptors>
<cxf:outFaultInterceptors>
<ref bean="logOutbound" />
</cxf:outFaultInterceptors>
</cxf:bus>
|

Unfortunately this does not work for my JAX-RS server. The
"StaxOutInterceptor.FORCE_START_DOCUMENT" is processed by the
StaxOutInterceptor and it is not in the chain when I'm using JAX-RS. It
could not be added manually since it depends on StaxOutEndingInterceptor
which is in the *ending phase and is called after JAXRSOutInterceptor.

I also tried implementing handler for the same purpose but without any
success.

Here is my JAXRS server configuration:

|<jaxrs:server id="restServer" address="/rest">
<jaxrs:providers>
<ref bean="systemExceptionMapper" />
<ref bean="jaxbProvider" />
</jaxrs:providers>
<jaxrs:serviceBeans>
...
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
<entry key="feed" value="application/atom+xml" />
<entry key="html" value="text/html" />
</jaxrs:extensionMappings>
</jaxrs:server>
|

Any kind of help - ideas, suggestions, whatever will be appriciated!



Reply via email to