2 Replies Latest reply on Apr 3, 2007 5:40 AM by Magnus ahlamag

    Name of generated exception class

    Magnus ahlamag Newbie

      In my endpoint implementation I have a user-defined exception thrown by some operations. The generated wsdl then looks something like:

      <xs:complexType name='AuthorizationException'>
       <xs:element minOccurs='0' name='message' type='xs:string'/>
       <operation name='read'>
       <fault name='AuthorizationException'>
       <soap:fault name='AuthorizationException' use='literal'/>

      From this wsdl wsconsume generates the following client-side artifacts:
      AuthorizationException (jaxb type)
      AuthorizationException_Exception (java exception)

      In the client I then I then get some awkward code like

      try {...}
      catch (AuthorizationException_Exception ex) {...}

      To get around these problems I defined a custom jax-ws binding, which is then provided to wsconsume:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
       <bindings node="wsdl:definitions">
       <package name="com.test"/>
       <bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://com.test']">
       <jaxb:package name="com.test.jaxb"/>

      basically this puts jaxws and jaxb generated artifacts into separate packages.

      However, this works only if I remove the 'package' attribute from the wsconsume task. From this I conclude that the 'package' attribute takes precedence over any custom bindings. Why is this so?

      Is there any other way to get nice exception class names with wsconsume?


        • 1. Re: Name of generated exception class
          Jason Greene Master

          Yes, the package name passed to wsconsume is an override, and is not really part of the standard. It's just their for ease of use.

          You can change the name of the exception class by using
          <jaxws:class name="MyNewException" node="..."/> to point to the wsdl:fault element.

          You can also change the name of the fault bean by using a JAXB customization that points to the schema complex type:

          <jaxb:class name="AuthorizationFaultBean" node="..."/>


          • 2. Re: Name of generated exception class
            Magnus ahlamag Newbie

            Thanks for the reply.

            It seems like in the wsconsume task, the package name specified in the 'package' attribute takes precedence over any custom jaxws or jaxb bindings.

            Wouldn't it be more appropriate to initially apply any custom bindings and then fall back to the value of the 'package' attribute only if no appropriate bindings are available?

            Lp, Magnus