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

Incompatible fault type is generated in the wsdl if no setter method in Exception

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      with the exception class below , it only has a get*** method for the
      info property.

      @WebFault
      public TestException extends Exception {
      private String message = null;

      public TestException () {
      }

      public TestException (String message)

      { this.message = message; }

      public String getInfo()

      { return message; }

      }

      With the RI wsgen command, the generated schema type is :
      RI:
      <xs:complexType name="TestException">
      <xs:sequence>
      <xs:element name="info" type="xs:string" minOccurs="0"/>
      <xs:element name="message" type="xs:string" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>

      If using CXF tool or on the CXF runtime, the generated schema type for the
      exception is :

      <xs:element name="TestException" type="tns:TestException"/>
      <xs:complexType name="TestException">
      <xs:sequence/>
      </xs:complexType>

      With the JaxWS spec, 3.7 Service Specific Exception, considering that no
      getFaultInfo or faultBean in WebFault annotation is provided, the
      special algorithm will be used to map the exception to jaxb bean, one of
      the steps write below:

      For each getter in the exception and its superclasses, a property of the
      same type and name is added to
      the bean. All the getter methods except
      getMessagefromjava.lang.Throwabletype hierarchy
      are excluded from the list of getters to be mapped.

      Seems that only getter method is required, with the current codes in static
      boolean JAXBContextInitializer.isMethodAccepted, it will check whether the
      setter exists. I am thinking that this is not required for this scenario,
      as we only need to read the information from the user exception.

      The patch will return true is the getter method has no corresponding setter method to let CXF comply with the jax-ws 2.2 spec:
      For each getter in the exception and its superclasses, a property of the
      same type and name is added to
      the bean. All the getter methods except
      getMessagefromjava.lang.Throwabletype hierarchy
      are excluded from the list of getters to be mapped.

      Attachments

        1. CXF-4594-testnew.patch
          9 kB
          Iris Ding
        2. CXF-4594.patch
          6 kB
          Iris Ding
        3. CXF-4594-test.patch
          8 kB
          Freeman Yue Fang

        Activity

          People

            ffang Freeman Yue Fang
            irisding Iris Ding
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: