I've found the beginning of a solution for this problem, but I still have questions.

Now my server code looks like :

try{
...
} catch (MyException e) {
String code = "Server";
String faultString = "The following exception has been raised by the server : " + e.getClass().getName();
String actor = "Server";

IIOMetadataNode[] elements = new IIOMetadataNode[1];
IIOMetadataNode element1 = new IIOMetadataNode("why");
element1.setAttribute("value", e.why);
elements[0] = element1;
throw new org.apache.axis.AxisFault(code, faultString, actor, elements);
}

The SOAP message I receive is :

<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/";>ns1:Server</faultcode>
<faultstring>The following exception has been raised by the server : MyException</faultstring>
<faultactor>Server</faultactor>
<detail>
<why value="Just to test MyException"/>
</detail>
</soapenv:Fault>
</soapenv:Body>

I've also tried to use child nodes for "why" and it works. The only thing is that I would like to have :
<why>Just to test BadRecord</why>
instead of :
<why value="Just to test BadRecord"/>
but I can't find a way to do that (I've tried with setUserObject and setNodeValue but it doesn't work).

So it works quite well if the exception has simple fields (here "e.why" is a String).
I think that if the exception contains a "complex-type" field (arrays, enumeration...), we have to convert this attribute of the exception to an Element[]. Or is there a better way to do that ??

Thanks,
Olivier


Olivier Gauwin wrote:

Hi,

I have a WSDL file with an exception defined as a complexType. A message based on this exception is also defined, and used in a <fault message=...> field of an operation.

I try to implement the server. I've already read this thread : http://marc.theaimsgroup.com/?l=axis-user&m=103712254801803&w=2 but the conclusion is not clear... If I throw my exception in the server code, then an AxisFault is created, and the client receives a Server.userException, not my Exception (and its fields...) :

<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>MyExceptions.BadRecord</faultstring>
<detail>
...

Is there an easy way to do that ??
(I've tried with Axis1.0 and the CVS sources too).

Thanks a lot,
Olivier




Reply via email to