Hi Nikolay

On 21/10/11 16:53, Nikolay Aleksiev wrote:
Hello Sergey,

first I updated to CXF 2.4.3. After going through JAXBElementProvider I
noticed that, I experience my issue only for marshalCollection and it is
fine for marshallToOutputStream. When marshaling collection the code is
not putting the xml header. I'm not sure if it is a mistake or is done
on purpose.

After introducing domain objects for my collection methods everything is
working fine.

ok, thanks for your help here. It's just an omission that the xml PI is not added; and I actually see a similar issue when StaxUtils are involved so I'll play a bit more with this issue later on

Cheers, Sergey


Thank you for your time and sorry for my mistake. Most of my methods
were returning collections so I have noticed the difference.

Cheers and a nice weekend,
Nikolay

On 10/21/2011 05:23 PM, Sergey Beryozkin wrote:
So for some reasons it is lost in your case, strange...
I think JAXRSClientServerBookTest should work on 2.3.3 as some of the
old JAXRSClientServerBookTest tests match the responses against the
test resources.
Would it be possible for you to put a breakpoint in
JAXBElementProvider.writeTo and see what may be happening in your case ?
Alternatively please provide a test maven project

thanks, Sergey

On 21/10/11 14:17, Nikolay Aleksiev wrote:
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