axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mauro Molinari <>
Subject Re: different java package for wsdl2java generated fault classes (Axis2 1.3)
Date Thu, 06 Dec 2007 08:39:19 GMT
Amila Suriarachchi ha scritto:
> fault class package is based on the wsdl targetnamespace. try to codegen 
> using the -p option to
> specify an different package for wsdl namesapce components.

If I understood Leon right, he means that exception classes are 
generated in the same package of the skeleton, that is the target 
namespace of the wsdl.

Leon, from my experience, WSDL2Java behaves as follows:

- it generates an ADBBean for the type defined in the schema 
corresponding to the description of the fault message: this class is put 
in the package corresponding to the target namespace of the schema
- it generates an exception class with the same name of the <wsdl:fault> 
defined for an operation: this class is put in the package corresponding 
to the target namespace of the package

Suppose in your WSDL you have:
<wsdl:operation name="myOp">
   <wsdl:input message="wsdl:myOpRequest"></wsdl:input>
   <wsdl:output message="wsdl:myOpResponse"></wsdl:output>
   <wsdl:fault name="MyException"

<wsdl:message name="MyException">
   <wsdl:part name="parameters"

while, in the schema, you have:
<element name="MyFaultMessage">
       <!-- [cut] -->

Now, suppose the namespaces are as follows:
- prefix "schema" = target namespace of the schema =
- prefix "wsdl" = target namespace of the WSDL =

WSDL2Java generates the following:
- com.myhost.myservice.type.MyFaultMessage, which is an ADBBean 
describing the details of the fault message
- com.myhost.myservice.wsdl.MyException, which is an extension of 
java.lang.Exception, with a property named "faultMessage" of type 

The skeleton is also put in com.myhost.myservice.wsdl. I don't think 
this is customizable at the moment. If you want to share the same 
exceptions and faults within multiple services, I did as follows:
- I created a common XSD schema, that I import in every WSDL
- in this schema, there's a global element defined which describes my 
fault message
- the schema has a target namespace which is mapped to the package 
containing types that I want to share between services implementations
- then, I manually created an extension of java.lang.Exception with a 
property (+ getter/setter) of the type of the fault message and I put 
this exception in another shared package
- then, every time I generate a new web service skeleton, I delete the 
generated exceptions and refactor the skeleton and the message receiver 
so that they use the shared exception defined manually, instead of the 
auto-generated ones

Obviously, this is a problem if you want (or need) to completely rely on 

Hope this helps.

Mauro Molinari
Software Developer

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message