Java - AXIS 1.4: Changing the text of the faultcode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Java - AXIS 1.4: Changing the text of the faultcode

Reza Eslami-2
Hi there,

i was wondering whether there is a way to change the faultcode in Axis,
which is sent back from the framework after a normal SoapException is thrown
in a Java Web Service.

Here is the xml-text that is recieved:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.apache.soap.SOAPException:my error code</faultstring>
<detail>
<faultData xsi:type="ns1:SOAPException" xmlns:ns1="http://soap.apache.org">
<faultCode xsi:type="xsd:string" xsi:nil="true"/>
<message xsi:type="xsd:string">my error text</message>
<targetException xsi:type="xsd:anyType" xsi:nil="true"/>
<rootException xsi:type="xsd:anyType" xsi:nil="true"/>
<cause xsi:nil="true"/>
</faultData>
<ns2:hostname
xmlns:ns2="http://xml.apache.org/axis/">myServer</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>  
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

Is there any way to change or configure Axis in such a way, that the
generated XML for the execption looks like this?

<SOAP-ENV:Body>
<SOAP-ENV:Fault>
  <faultcode>007</faultcode>
  <faultstring>my error text</faultstring>
<detail>
        <!-- some kind of error code -->
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

in Java i use this code to throw the exception:
        throw myEXCEPTION;

and i have used this as a defition for myEXCEPTION:

import org.apache.soap.SOAPException;

public final static SOAPException myEXCEPTION = new SOAPException();
myEXCEPTION.setFaultCode("007");
myEXCEPTION.setMessage("my error text");

In the WSDL - File the corresponding Exception parts look like these:

<schema targetNamespace="http://soap.apache.org"
xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="SOAPException">
    <sequence>
     <element name="faultCode" nillable="true" type="xsd:string"/>
     <element name="message" nillable="true" type="xsd:string"/>
     <element name="targetException" nillable="true" type="xsd:anyType"/>
     <element name="rootException" nillable="true" type="xsd:anyType"/>
    </sequence>
   </complexType>
   <element name="SOAPException" nillable="true" type="tns4:SOAPException"/>
  </schema>

   <wsdl:message name="SOAPException">

      <wsdl:part name="fault" type="tns4:SOAPException"/>

   </wsdl:message>

and in every <wsdl:operation> there is then also this line:

         <wsdl:fault message="impl:SOAPException" name="SOAPException"/>

So my question is: can i somehow make the created exception look like the
one i provided? (this is needed, because in the old application this was the
returned error text and the new error needs to be the same way to work
properly)

i hope there is someone who can help me out. Any help will be greatly
apprechiated.

Best,

Reza Eslami


---
Dipl.-Inform. Reza Eslami
INNOVA Beratungsgesellschaft mbH
Emil-Figge-Straße 91
44277 Dortmund
Tel: +49 (0) 231 / 97677 - 556,  Fax - 519
eMail: [hidden email]
Homepage: www.innovaberatung.com

Geschäftsführer: Dr. Volker Zurwehn
Sitz der Gesellschaft: Dortmund
Registergericht Dortmund, HRB 14888
Steuernummer 315/5749/0367
---
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]