Hi, sorry for a delay.

I can not reproduce it, it works fine for me on the trunk and the same code does live in 2.4.x.
I'm wondering what can be interfering in your case though.
Can you also try CXF 2.5.0 ? and may be provide a simple Maven-based test case ?

This is my client code:

@Test
    public void testGetModel() {
        BookStore store =
JAXRSClientFactory.create("http://localhost:"; + PORT, BookStore.class);
        TestModel model = store.getModel();
        System.out.println(model.getName());
    }

    @Test
    public void testGetModels() {
        BookStore store =
JAXRSClientFactory.create("http://localhost:"; + PORT, BookStore.class);
        List<TestModel> models = store.getModels();
        for (TestModel model : models) {
            System.out.println(model.getName());
        }
    }

where store.getModel() and store.getModels() are implemented exactly as you show below; it works fine for me

Sergey

On 02/11/11 10:31, sotiris wrote:
Hi Sergey,

Thanks for your reply. My bad I didn't mention the version I was trying it
on in the first place.
It was 2.3.1, so after your suggestion I retested it with 2.4.3, but
unfortunately with the same results.

For a minute I thought that it might be my structures that are causing this
behavior, so I did a very simple test with the simplest possible model.

The result is unfortunately the same.

I'm attaching the code in case there is something obvious that I'm missing.

---------------------------TestModel---------------------------------
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="testRoot")
@XmlAccessorType(XmlAccessType.FIELD)
public class TestModel {
        
        private String name;

        @XmlAttribute
        private String attr;
        

        public TestModel() {
        }

        public TestModel(String name, String attr) {
                this.name = name;
                this.attr = attr;
        }

        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }

        public String getAttr() {
                return attr;
        }

        public void setAttr(String attr) {
                this.attr = attr;
        }
        
}
---------------------------TestManager-------------------------------
import java.util.List;

public interface TestManager {
        
        TestModel getModel();
        
        List<TestModel>  getModels();
}

---------------------------TestManagerImpl---------------------------
import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.springframework.stereotype.Service;

import TestManager;
import TestModel;

@Service("testManager")
public class TestManagerImpl implements TestManager {
        
        @GET
        @Path("/model/")
        public TestModel getModel() {
                return new TestModel("test", "attr");
        }

        @GET
        @Path("/models/")
        public List<TestModel>  getModels() {
                ArrayList<TestModel>  models = new ArrayList<TestModel>();
                models.add(new TestModel("test1", "attr"));
                models.add(new TestModel("test2", "attr"));
                return models;
        }

}


-----------------------------------cxf-servlet.xml----------------------------------
<jaxrs:server address="/rs/test/">
         <jaxrs:serviceBeans>
             <ref bean="testManager"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <ref bean="ignoreNsResponseHandler"/>
         </jaxrs:providers>
         <jaxrs:extensionMappings>
             <entry key="json" value="application/json"/>
             <entry key="xml" value="application/xml"/>
             <entry key="feed" value="application/atom+xml"/>
         </jaxrs:extensionMappings>
</jaxrs:server>




-----Results------------
-----------rs/test/model/-------------
<testRoot attr="attr">
<name>test</name>
</testRoot>
-----------rs/test/models/------------
<testRoots><testRoot attr="attr"><name>test1</name></testRoot>JAXBException
occurred : Trying to output second root,<testRoot>. Trying to output second
root,<testRoot>.



Regards,
Sotiris

--
View this message in context: 
http://cxf.547215.n5.nabble.com/Removing-XML-namespaces-and-prefixes-tp565416p4957728.html
Sent from the cxf-user mailing list archive at Nabble.com.


--
Sergey Beryozkin

http://sberyozkin.blogspot.com

Talend Community Coders
http://coders.talend.com/

Reply via email to