You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "x-fo.net" <in...@x-fo.net> on 2010/07/10 13:44:55 UTC

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: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: How to pass costum error messages to AxisFault

Posted by "VANEKEM, Olivier" <Ol...@SAGA.BE>.
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:info@x-fo.net] 
Sent: samedi 10 juillet 2010 13:45
To: java-user@axis.apache.org
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: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: How to pass costum error messages to AxisFault

Posted by Martin Gainty <mg...@hotmail.com>.
thats one solution


the other would be to create a class that overrides org.apache.axis2.AxisFault then override getMessage()

    /**
     * Returns the detail message, including the message from the cause, if any, of this exception.
     *
     * @return the detail message
     */

    @Override
    public String getMessage() {
        //return message;

        return customMessage;
    }

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.



 

> Subject: RE: How to pass costum error messages to AxisFault
> Date: Mon, 12 Jul 2010 08:29:37 -0500
> From: Meeusen.Christopher@mayo.edu
> To: java-user@axis.apache.org
> 
> In your code example, you don't actually throw the error back, you're
> just writing the stacktrace to stderr " e1.printStackTrace();". You
> need to declare your method to throw an exception, then in your catch
> you can log the exception, but if you want the client to see it you must
> throw it back to them. Try adding "throw e1;" like this:
> 
> > 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();
> > throw e1;
> > }
> > }
> 
> Chris
> 
> -----Original Message-----
> From:
> java-user-return-83245-Meeusen.Christopher=mayo.edu@axis.apache.org
> [mailto:java-user-return-83245-Meeusen.Christopher=mayo.edu@axis.apache.
> org] On Behalf Of x-fo.net
> Sent: Monday, July 12, 2010 6:19 AM
> To: java-user@axis.apache.org
> Subject: AW: How to pass costum error messages to AxisFault
> 
> Hi,
> 
> do you have an example?
> thanks
> 
> br
> 
> Markus
> 
> -----Ursprungliche Nachricht-----
> Von: Meeusen, Christopher W. [mailto:Meeusen.Christopher@mayo.edu]
> Gesendet: Samstag, 10. Juli 2010 16:40
> An: java-user@axis.apache.org
> Cc: java-user@axis.apache.org
> Betreff: Re: How to pass costum error messages to AxisFault
> 
> 
> In our services we throw a subclass of java.lang.exception, and the
> client sees the exception message. I'm not sure what extending
> axisfault buys you.
> 
> Chris
> 
> On Jul 10, 2010, at 6:46, "x-fo.net" <in...@x-fo.net> wrote:
> 
> > 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: java-user-unsubscribe@axis.apache.org
> > For additional commands, e-mail: java-user-help@axis.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
> 
 		 	   		  
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

RE: How to pass costum error messages to AxisFault

Posted by "Meeusen, Christopher W." <Me...@mayo.edu>.
In your code example, you don't actually throw the error back, you're
just writing the stacktrace to stderr " e1.printStackTrace();".  You
need to declare your method to throw an exception, then in your catch
you can log the exception, but if you want the client to see it you must
throw it back to them.  Try adding "throw e1;" like this:

> 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();
>                throw e1;
>            }
>        }

Chris

-----Original Message-----
From:
java-user-return-83245-Meeusen.Christopher=mayo.edu@axis.apache.org
[mailto:java-user-return-83245-Meeusen.Christopher=mayo.edu@axis.apache.
org] On Behalf Of x-fo.net
Sent: Monday, July 12, 2010 6:19 AM
To: java-user@axis.apache.org
Subject: AW: How to pass costum error messages to AxisFault

Hi,

do you have an example?
thanks

br

Markus

-----Ursprungliche Nachricht-----
Von: Meeusen, Christopher W. [mailto:Meeusen.Christopher@mayo.edu]
Gesendet: Samstag, 10. Juli 2010 16:40
An: java-user@axis.apache.org
Cc: java-user@axis.apache.org
Betreff: Re: How to pass costum error messages to AxisFault


In our services we throw a subclass of java.lang.exception, and the
client sees the exception message.  I'm not sure what extending
axisfault buys you.

Chris

On Jul 10, 2010, at 6:46, "x-fo.net" <in...@x-fo.net> wrote:

> 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: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


AW: How to pass costum error messages to AxisFault

Posted by "x-fo.net" <in...@x-fo.net>.
Hi,

do you have an example?
thanks

br

Markus

-----Ursprungliche Nachricht-----
Von: Meeusen, Christopher W. [mailto:Meeusen.Christopher@mayo.edu]
Gesendet: Samstag, 10. Juli 2010 16:40
An: java-user@axis.apache.org
Cc: java-user@axis.apache.org
Betreff: Re: How to pass costum error messages to AxisFault


In our services we throw a subclass of java.lang.exception, and the
client sees the exception message.  I'm not sure what extending
axisfault buys you.

Chris

On Jul 10, 2010, at 6:46, "x-fo.net" <in...@x-fo.net> wrote:

> 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: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: How to pass costum error messages to AxisFault

Posted by "Meeusen, Christopher W." <Me...@mayo.edu>.
In our services we throw a subclass of java.lang.exception, and the  
client sees the exception message.  I'm not sure what extending  
axisfault buys you.

Chris

On Jul 10, 2010, at 6:46, "x-fo.net" <in...@x-fo.net> wrote:

> 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: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org