axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anne Thomas Manes" <>
Subject RE: WSDL2Java does not generate custom exception
Date Tue, 26 Oct 2004 22:35:02 GMT
Note, though, that fault messages MUST be defined as document/literal rather
than rpc/encoded, per the WSDL 1.1 specification [1]: 

3.6 soap:fault
The soap:fault element specifies the contents of the contents of the SOAP
Fault Details element. It is patterned after the soap:body element (see
section 3.5).

<definitions .... >
    <binding .... >
        <operation .... >
               <soap:fault name="nmtoken" use="literal|encoded"
                                 encodingStyle="uri-list"? namespace="uri"?>

The name attribute relates the soap:fault to the wsdl:fault defined for the

The fault message MUST have a single part. The use, encodingStyle and
namespace attributes are all used in the same way as with soap:body (see
section 3.5), only style="document" is assumed since faults do not contain

Also see WS-I Basic Profile [2]:

4.4.2 Bindings and Faults
There are several interpretations for how wsdl:part elements that describe
soapbind:fault, soapbind:header, and soapbind:headerfault may be defined. 

R2205 A wsdl:binding in a DESCRIPTION MUST refer, in each of its
soapbind:header, soapbind:headerfault and soapbind:fault elements, only to
wsdl:part element(s) that have been defined using the element attribute. 

Because faults and headers do not contain parameters, soapbind:fault,
soapbind:header and soapbind:headerfault assume, per WSDL 1.1, that the
value of the style attribute is "document". R2204 requires that all
wsdl:part elements with a style attribute whose value is "document" that are
bound to soapbind:body be defined using the element attribute. This
requirement does the same for soapbind:fault, soapbind:header and
soapbind:headerfault elements.


- Anne

-----Original Message-----
From: [] 
Sent: Monday, October 25, 2004 11:21 AM
Subject: Re: WSDL2Java does not generate custom exception


First define your exception as a complex type as follows:

  <complexType name="SystemFailureException">
  	  <element name="sourceException" nillable="true"

Next define the message as follows:

  <message name="SystemFailureException">
	<part name="fault" type="ex1:SystemFailureException"/>

N.B. The part name attribute is "fault"

Next define the operation in the portType section of your WSDL as follows:

<operation name="getChargeForProductMigrationOrder">
  <input message="tns:getChargeForProductMigrationOrderRequest"/>
  <output message="tns:getChargeForProductMigrationOrderResponse"/>
  <fault message="tns:SystemFailureException"

Lastly in the binding section define the operation as follows:

  <operation name="getChargeForProductMigrationOrder">
	<soap:operation soapAction="urn:getChargeForProductMigrationOrder"/>
namespace="urn:ESelfcareSoap" use="encoded"/>
namespace="urn:ESelfcareSoap" use="encoded"/>
	<fault name="SystemFailureException">
namespace="urn:SystemFailureException" use="encoded"/>

Pay attention to the name spaces'

This will then generate the Impl class with the correct throws clauses and 
these exceptions will be accessable directly within the client. These 
exceptions do not have to implement the Axis Fault.

Hope this helps


Quoting Los Morales <>:

> Hi,
> I have a question on how Axis 1.1 generates a user-defined fault through
> WSDL2Java tool.  I have defined a schema for an exception I want to return

> whenever something wrong happens during Web Service processing.  In my 
> custom WSDL, I specified this exception in the message, portType and
> definitions.  When I use the WSDL2Java tool to generate the server-side 
> skeleton, I do not see this exception in any throws clause or defined 
> anywhere except in the deploy.wsdd file.  The Exception class gets
> properly from the schema but does not look like Axis knows how to put this

> into the service.  I have attached portions of my code below.  Any advice 
> would be appreciated.  Thanks!
> -los
> #### Schema ####
> ....
>     <xsd:element name="ProcessingFault" type="ProcessingProblemType"/>
>     <xsd:complexType name="ProcessingProblemType">
>         <xsd:sequence>
>             <xsd:element name="exceptionMessage" type="xsd:string" 
> minOccurs="0"/>
> 	</xsd:sequence>
>     </xsd:complexType>
> ....
> ##############
> ### WSDL ####
> <!-- message definitions -->
> ....
>     <message name="DownloadError">
> 	<part name="error" element="fault:ProcessingFault"/>
>     </message>
> <!-- port type definitions -->
>     <portType name="DownloadPortType">
>         <operation name="downloadPrograms">
>          ....
> 	    <fault name="ProcessingProblemMessage"
>         </operation>
>     </portType>
> <!-- binding definitions -->
> ...
>     <fault name="ProcessingProblemMessage">
> 	    <soap:fault name="ProcessingProblemMessage" use="literal"/>
> 	</fault>
> ############
> _________________________________________________________________
> Get ready for school! Find articles, homework help and more in the Back to

> School Guide!

View raw message