axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frantz <>
Subject Problem with exceptions and "wrapped" style
Date Mon, 12 Dec 2005 14:28:51 GMT

By default, exceptions seem to be not properly serialized with 
literal/wrapped mode :

I am writing a Web Service connector for an existing Java application.
My connector exception extends the java.rmi.RemoteException one 
(according to the user's help advice) and I had registered a bean 
mapping for it.
It works well with the "RPC/encoded" mode. The issue is with the 
"literal - wrapped" mode : by default, the exceptions are not properly 
serialized so the client-side (which use wsdl2Java generated stubs) 
cannot re-interpret them (and throws them as AxisFaults).

the SOAP message looks like this (the custom exception namespace is 
missing) :

                   <cause xsi:nil="true"/>
                   <info>Could not find employee : foo</info>
                <ns1:hostname xmlns:ns1="">comp02</ns1:hostname>

instead of something like this :

                <ns1:fault xmlns:ns1="http://faults.samples">
                   <ns1:cause xsi:nil="true"/>
                   <ns1:info>Could not find employee : foo</ns1:info>
                <ns2:hostname xmlns:ns2="">comp02</ns2:hostname>

I have tried to set my own serializer to solve this problem but the 
"getSerializerAs" method of my factory was never called.
Is there a special treatment for exceptions (I probably missed 
something, but what...) ?

Lastly, I have investigated a bit further (on the samples/faults) and I 
have found that the problem can be solved by declaring the complete 
signature of methods which throws exceptions in the .wsdd deploying 
file. We can do this using the <fault> tag under the <operation> one.

example :
<operation name="getEmployee" qname="ns:getEmployee" 
returnQName="ns:getEmployeeReturn" returnType="ns:Employee" xmlns:ns="http://faults.samples">
       <parameter name="id" type="xsd:string" xmlns:xsd=""/>
       <fault name="NoSuchEmployeeFault" qname="fns:NoSuchEmployeeFault" xmlns:fns="http://faults.samples"

class="samples.faults.NoSuchEmployeeFault" type="tns:NoSuchEmployeeFault" xmlns:tns="http://faults.samples"/>

Finally, my program works fine. But, I think the solution I have found 
is not very handy because I have to write a large (more than 2x the size 
of the server interface) and boring deploying file.

Is it possible to declare somewhere, how Axis should serialize my 
exception, instead of re-declare each operation signatures ?

Frantz <>

View raw message