axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smcar...@spansurf.com
Subject Re: WSDL2Java does not generate custom exception
Date Mon, 25 Oct 2004 15:21:11 GMT
OK

First define your exception as a complex type as follows:

  <complexType name="SystemFailureException">
	<sequence>
  	  <element name="sourceException" nillable="true" type="xsd:anyType"/>
	</sequence>
  </complexType>

Next define the message as follows:

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

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" name="SystemFailureException"/>
</operation>


Lastly in the binding section define the operation as follows:

  <operation name="getChargeForProductMigrationOrder">
	<soap:operation soapAction="urn:getChargeForProductMigrationOrder"/>
	<input>
	  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="urn:ESelfcareSoap" use="encoded"/>
	</input>
	<output>
 	  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="urn:ESelfcareSoap" use="encoded"/>
	</output>
	<fault name="SystemFailureException">
	  <soap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="urn:SystemFailureException" use="encoded"/>
	</fault>
</operation>

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

Steve

Quoting Los Morales <moraleslos@hotmail.com>:

> Hi,
> 
> I have a question on how Axis 1.1 generates a user-defined fault through the
> 
> 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 binding
> 
> 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 generated
> 
> 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" message="tns:DownloadError"/>
>         </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! http://special.msn.com/network/04backtoschool.armx
> 
> 





Mime
View raw message