This is an example in our application that works correctly (is coded in
a method of a skeleton generated by WSDL2Java):

                        SOAPFactory soapFactory =
OMAbstractFactory.getSOAP11Factory();
                        SOAPFaultCode soapFaultCode =
soapFactory.createSOAPFaultCode();
                        SOAPFaultValue soapFaultValue =
soapFactory.createSOAPFaultValue(soapFaultCode);
                        soapFaultValue.setText(new
QName("http://test.org";, "TestFault", "test"));

                        SOAPFaultReason soapFaultReason =
soapFactory.createSOAPFaultReason();
                        SOAPFaultText soapFaultText =
soapFactory.createSOAPFaultText(soapFaultReason);
                        soapFaultText.setText("This is some
FaultReason");

                        SOAPFaultDetail soapFaultDetail =
soapFactory.createSOAPFaultDetail();
                        QName qName = new QName("http://someuri.org";,
"code");
                        OMElement codeElement =
soapFactory.createOMElement(qName, soapFaultDetail);
                        codeElement.setText(declarent.getFirstname());

                        AxisFault af = new AxisFault(null,
soapFaultReason, null, null, soapFaultDetail);
                        throw af;

Hth,

Olivier

-----Original Message-----
From: x-fo.net [mailto:[email protected]] 
Sent: samedi 10 juillet 2010 13:45
To: [email protected]
Subject: How to pass costum error messages to AxisFault

Hi,

I tried to pass costum errors to the axisFault, but I always get this:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
<soapenv:Body>
<soapenv:Fault>
  <faultcode>soapenv:Server</faultcode>
  <faultstring>unknown</faultstring>
  <detail />
  </soapenv:Fault>
  </soapenv:Body>
  </soapenv:Envelope>

---- this is my code for extending the AxisFault ----

import org.apache.axis2.AxisFault;

public class MYerror {
        public class MYAxisFault extends AxisFault {

                  public MYAxisFault(String faultCode, String message) {
                    super(faultCode, message);
                  }

}

}

---- this was in the exception placed ------------

private static int registerItem(
                        Item_type0 antragsstellerType0) throws
MYAxisFault {
....
} catch (ExcStamm e) {
                        String error= "";
                        error +="" + new Date()+"\n";

                        error +="No item found: " + e.Msg+"\n";
                        error +="item No: " + e.itemNo+"\n";


                        try {
                                throw new AxisFault("ExcStamm", error);
                        } catch (AxisFault e1) {

                                e1.printStackTrace();
                        }
                }

-----------------------

Thanks for your help

BR
Markus


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


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

Reply via email to