Hello,

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) :

<soapenv:Body>
         <soapenv:Fault>
            <faultcode>soapenv:Server.userException</faultcode>
            <faultstring>samples.faults.NoSuchEmployeeFault</faultstring>
            <detail>
               <samples.faults.NoSuchEmployeeFault>
                  <cause xsi:nil="true"/>
                  <info>Could not find employee : foo</info>
               </samples.faults.NoSuchEmployeeFault>
               <ns1:hostname 
xmlns:ns1="http://xml.apache.org/axis/";>comp02</ns1:hostname>
            </detail>
         </soapenv:Fault>
</soapenv:Body>

instead of something like this :

<soapenv:Body>
         <soapenv:Fault>
            <faultcode>soapenv:Server.userException</faultcode>
            <faultstring>samples.faults.NoSuchEmployeeFault</faultstring>
            <detail>
               <ns1:fault xmlns:ns1="http://faults.samples";>
                  <ns1:cause xsi:nil="true"/>
                  <ns1:info>Could not find employee : foo</ns1:info>
               </ns1:fault>
               <ns2:hostname 
xmlns:ns2="http://xml.apache.org/axis/";>comp02</ns2:hostname>
            </detail>
         </soapenv:Fault>
</soapenv:Body>

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="http://www.w3.org/2001/XMLSchema"/>
<fault name="NoSuchEmployeeFault" qname="fns:NoSuchEmployeeFault" xmlns:fns="http://faults.samples"; class="samples.faults.NoSuchEmployeeFault" type="tns:NoSuchEmployeeFault" xmlns:tns="http://faults.samples"/> </operation>

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 <[EMAIL PROTECTED]>

Reply via email to