Hi

Do you use the default JAXB provider or configure it somehow ?

Cheers, 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.

Reply via email to