Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5219

@XmlJavaTypeAdapter ignored for exception members

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      Given the interface:

      @javax.jws.WebService
      public interface WsIntfc {
          public void test() throws MyException;
      }
      

      And exception class:

      public class MyException extends Exception {
        private MyClass1 adapted = null;
        
        @XmlJavaTypeAdapter(Cl1ToCl2Adapter.class)
        public MyClass1 getAdapted() {
            return this.adapted;
        }
        
        public void setAdapted(MyClass1 adapted) {
            this.adapted = adapted;
        }
      }
      

      Along with:

      public class Cl1ToCl2Adapter extends XmlAdapter<MyClass2, MyClass1> {
        @Override
        public MyClass1 unmarshal(MyClass2 v) throws Exception {
            MyClass1 mc1 = new MyClass1();
            mc1.setName(v.getFile());
            return mc1;
        }
      
        @Override
        public MyClass2 marshal(MyClass1 v) throws Exception {
            MyClass2 mc2 = new MyClass2();
            mc2.setFile(v.getName());
            return mc2;
        }
      }
      
      public class MyClass1 {
        private String name = null;
        
        public String getName() {
          return this.name;
        }
        
        public void setName(String name) {
          this.name = name;
        }
        
      }
      
      public class MyClass2 {
        private String file = null;
        
        public String getFile() {
          return this.file;
        }
        
        public void setFile(String file) {
          this.file = file;
        }
      }
      

      I get the following schema output:

      <xs:complexType name="myClass1">
        <xs:sequence>
          <xs:element minOccurs="0" name="name" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="MyException">
        <xs:sequence/>
      </xs:complexType>
      

      I should expect myClass2 defined in the schema and referenced by MyException.

      Attachments

        1. cxf5219.diff
          2 kB
          Kyle Lape

        Issue Links

          Activity

            People

              ema Jim Ma
              klape Kyle Lape
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: