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 Jérôme Mainaud <jm...@kleegroup.com> on 2006/09/05 19:21:15 UTC
[Axis2] Howto send custom AxisFault that respect my WSDL ?
Hello,
The context :
I'm using Axis2 1.0
I have a service defined in wsdl (see the attachement : upload.wsdl)
I call the operation initUpload.
When a javaException occurs in the method, I send a AxisFault build with
this method :
public static AxisFault newErreurJava(Exception e) {
AxisFault ex = new AxisFault(e.toString(), new
QName(WsConstantes.NS_UPLOAD_SERVICE, "erreurJava"));
// Extraction de la pile d'erreur
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
// Création du détail
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace nsUpl =
factory.createOMNamespace(WsConstantes.NS_UPLOAD_TYPES, "upl");
OMElement detail = factory.createOMElement("javaException", nsUpl);
factory.createOMElement("class", nsUpl,
detail).setText(e.getClass().getName());
factory.createOMElement("stack", nsUpl,
detail).setText(sw.toString());
ex.setDetail(detail);
return ex;
}
I naively thought that I would get a correct SOAP:Fault answer with
this. Instead, I get what is in response.xml
I have seen in org.apache.axis2.receivers.RawXMLINOutMessageReceiver
public void invokeBusinessLogic(MessageContext msgContext,
MessageContext newmsgContext)
throws AxisFault {
try {
/* .... */
OMElement result;
try {
result = (OMElement) method.invoke(obj, args);
} catch (Exception e) {
throw new AxisFault(e.getMessage());
}
/* ... */
} catch (Exception e) {
throw AxisFault.makeFault(e);
}
}
And in AxisFault :
public static AxisFault makeFault(Exception e) {
if (e instanceof InvocationTargetException) {
Throwable t = ((InvocationTargetException)
e).getTargetException();
if (t instanceof Exception) {
e = (Exception) t;
}
}
if (e instanceof AxisFault) {
return (AxisFault) e;
}
return new AxisFault(e);
}
It seams that the catch around the refective invokation kills the
InvocationTargetException that would be dealed by AxisFault.makeFault()
otherwise.
But because Axis and webservices in general are new for me, I'm not sure
about it.
What can I do to get a SOAP:Fault that is conform to my wsdl ?
Thank you !
--
Jérôme Mainaud Klee Group
jmainaud@kleegroup.com <http://www.kleegroup.com/>
+ 33 146 295 825 Tel: + 33 146 292 525
Fax: + 33 146 292 529
Re: [Axis2] Howto send custom AxisFault that respect my WSDL ?
Posted by Jérôme Mainaud <jm...@kleegroup.com>.
That would be great!
Thank you.
--
Jérôme Mainaud Klee Group
jmainaud@kleegroup.com <http://www.kleegroup.com/>
+ 33 146 295 825 Tel: + 33 146 292 525
Fax: + 33 146 292 529
robert lazarski a écrit :
> We're hoping for the first release candidate around mid-september and
> an official release soon after.
>
> HTH,
> Robert
>
> On 9/6/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
>> It worked as expected with the today's nightly.
>>
>> When is the next version to be released ?
>> Because I will need it to work in a couple of months and an officially
>> released version would be better.
>>
>> Thank you.
>>
>> --
>> Jérôme Mainaud Klee Group
>> jmainaud@kleegroup.com <http://www.kleegroup.com/>
>> + 33 146 295 825 Tel: + 33 146 292 525
>> Fax: + 33 146 292 529
>>
>>
>> robert lazarski a écrit :
>> > Can you try the nightlies?
>> >
>> > http://people.apache.org/dist/axis2/nightly/
>> >
>> > If that does not work, please file a jira and upload your wsdl.
>> >
>> > Robert
>> >
>> > On 9/5/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
>> >> Hello,
>> >>
>> >> The context :
>> >> I'm using Axis2 1.0
>> >> I have a service defined in wsdl (see the attachement : upload.wsdl)
>> >> I call the operation initUpload.
>> >> When a javaException occurs in the method, I send a AxisFault build
>> with
>> >> this method :
>> >>
>> >> public static AxisFault newErreurJava(Exception e) {
>> >> AxisFault ex = new AxisFault(e.toString(), new
>> >> QName(WsConstantes.NS_UPLOAD_SERVICE, "erreurJava"));
>> >>
>> >> // Extraction de la pile d'erreur
>> >> StringWriter sw = new StringWriter();
>> >> PrintWriter pw = new PrintWriter(sw);
>> >> e.printStackTrace(pw);
>> >> pw.close();
>> >>
>> >> // Création du détail
>> >> OMFactory factory = OMAbstractFactory.getOMFactory();
>> >> OMNamespace nsUpl =
>> >> factory.createOMNamespace(WsConstantes.NS_UPLOAD_TYPES, "upl");
>> >> OMElement detail = factory.createOMElement("javaException",
>> >> nsUpl);
>> >> factory.createOMElement("class", nsUpl,
>> >> detail).setText(e.getClass().getName());
>> >> factory.createOMElement("stack", nsUpl,
>> >> detail).setText(sw.toString());
>> >> ex.setDetail(detail);
>> >>
>> >> return ex;
>> >> }
>> >>
>> >> I naively thought that I would get a correct SOAP:Fault answer with
>> >> this. Instead, I get what is in response.xml
>> >>
>> >>
>> >> I have seen in org.apache.axis2.receivers.RawXMLINOutMessageReceiver
>> >>
>> >> public void invokeBusinessLogic(MessageContext msgContext,
>> >> MessageContext newmsgContext)
>> >> throws AxisFault {
>> >> try {
>> >>
>> >> /* .... */
>> >>
>> >> OMElement result;
>> >> try {
>> >> result = (OMElement) method.invoke(obj, args);
>> >> } catch (Exception e) {
>> >> throw new AxisFault(e.getMessage());
>> >> }
>> >>
>> >> /* ... */
>> >>
>> >> } catch (Exception e) {
>> >> throw AxisFault.makeFault(e);
>> >> }
>> >> }
>> >>
>> >> And in AxisFault :
>> >> public static AxisFault makeFault(Exception e) {
>> >> if (e instanceof InvocationTargetException) {
>> >> Throwable t = ((InvocationTargetException)
>> >> e).getTargetException();
>> >>
>> >> if (t instanceof Exception) {
>> >> e = (Exception) t;
>> >> }
>> >> }
>> >>
>> >> if (e instanceof AxisFault) {
>> >> return (AxisFault) e;
>> >> }
>> >>
>> >> return new AxisFault(e);
>> >> }
>> >>
>> >> It seams that the catch around the refective invokation kills the
>> >> InvocationTargetException that would be dealed by
>> AxisFault.makeFault()
>> >> otherwise.
>> >>
>> >> But because Axis and webservices in general are new for me, I'm not
>> sure
>> >> about it.
>> >>
>> >> What can I do to get a SOAP:Fault that is conform to my wsdl ?
>> >> Thank you !
>> >>
>> >> --
>> >> Jérôme Mainaud Klee Group
>> >> jmainaud@kleegroup.com <http://www.kleegroup.com/>
>> >> + 33 146 295 825 Tel: + 33 146 292 525
>> >> Fax: + 33 146 292 529
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [Axis2] Howto send custom AxisFault that respect my WSDL ?
Posted by robert lazarski <ro...@gmail.com>.
We're hoping for the first release candidate around mid-september and
an official release soon after.
HTH,
Robert
On 9/6/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
> It worked as expected with the today's nightly.
>
> When is the next version to be released ?
> Because I will need it to work in a couple of months and an officially
> released version would be better.
>
> Thank you.
>
> --
> Jérôme Mainaud Klee Group
> jmainaud@kleegroup.com <http://www.kleegroup.com/>
> + 33 146 295 825 Tel: + 33 146 292 525
> Fax: + 33 146 292 529
>
>
> robert lazarski a écrit :
> > Can you try the nightlies?
> >
> > http://people.apache.org/dist/axis2/nightly/
> >
> > If that does not work, please file a jira and upload your wsdl.
> >
> > Robert
> >
> > On 9/5/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
> >> Hello,
> >>
> >> The context :
> >> I'm using Axis2 1.0
> >> I have a service defined in wsdl (see the attachement : upload.wsdl)
> >> I call the operation initUpload.
> >> When a javaException occurs in the method, I send a AxisFault build with
> >> this method :
> >>
> >> public static AxisFault newErreurJava(Exception e) {
> >> AxisFault ex = new AxisFault(e.toString(), new
> >> QName(WsConstantes.NS_UPLOAD_SERVICE, "erreurJava"));
> >>
> >> // Extraction de la pile d'erreur
> >> StringWriter sw = new StringWriter();
> >> PrintWriter pw = new PrintWriter(sw);
> >> e.printStackTrace(pw);
> >> pw.close();
> >>
> >> // Création du détail
> >> OMFactory factory = OMAbstractFactory.getOMFactory();
> >> OMNamespace nsUpl =
> >> factory.createOMNamespace(WsConstantes.NS_UPLOAD_TYPES, "upl");
> >> OMElement detail = factory.createOMElement("javaException",
> >> nsUpl);
> >> factory.createOMElement("class", nsUpl,
> >> detail).setText(e.getClass().getName());
> >> factory.createOMElement("stack", nsUpl,
> >> detail).setText(sw.toString());
> >> ex.setDetail(detail);
> >>
> >> return ex;
> >> }
> >>
> >> I naively thought that I would get a correct SOAP:Fault answer with
> >> this. Instead, I get what is in response.xml
> >>
> >>
> >> I have seen in org.apache.axis2.receivers.RawXMLINOutMessageReceiver
> >>
> >> public void invokeBusinessLogic(MessageContext msgContext,
> >> MessageContext newmsgContext)
> >> throws AxisFault {
> >> try {
> >>
> >> /* .... */
> >>
> >> OMElement result;
> >> try {
> >> result = (OMElement) method.invoke(obj, args);
> >> } catch (Exception e) {
> >> throw new AxisFault(e.getMessage());
> >> }
> >>
> >> /* ... */
> >>
> >> } catch (Exception e) {
> >> throw AxisFault.makeFault(e);
> >> }
> >> }
> >>
> >> And in AxisFault :
> >> public static AxisFault makeFault(Exception e) {
> >> if (e instanceof InvocationTargetException) {
> >> Throwable t = ((InvocationTargetException)
> >> e).getTargetException();
> >>
> >> if (t instanceof Exception) {
> >> e = (Exception) t;
> >> }
> >> }
> >>
> >> if (e instanceof AxisFault) {
> >> return (AxisFault) e;
> >> }
> >>
> >> return new AxisFault(e);
> >> }
> >>
> >> It seams that the catch around the refective invokation kills the
> >> InvocationTargetException that would be dealed by AxisFault.makeFault()
> >> otherwise.
> >>
> >> But because Axis and webservices in general are new for me, I'm not sure
> >> about it.
> >>
> >> What can I do to get a SOAP:Fault that is conform to my wsdl ?
> >> Thank you !
> >>
> >> --
> >> Jérôme Mainaud Klee Group
> >> jmainaud@kleegroup.com <http://www.kleegroup.com/>
> >> + 33 146 295 825 Tel: + 33 146 292 525
> >> Fax: + 33 146 292 529
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [Axis2] Howto send custom AxisFault that respect my WSDL ?
Posted by Jérôme Mainaud <jm...@kleegroup.com>.
It worked as expected with the today's nightly.
When is the next version to be released ?
Because I will need it to work in a couple of months and an officially
released version would be better.
Thank you.
--
Jérôme Mainaud Klee Group
jmainaud@kleegroup.com <http://www.kleegroup.com/>
+ 33 146 295 825 Tel: + 33 146 292 525
Fax: + 33 146 292 529
robert lazarski a écrit :
> Can you try the nightlies?
>
> http://people.apache.org/dist/axis2/nightly/
>
> If that does not work, please file a jira and upload your wsdl.
>
> Robert
>
> On 9/5/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
>> Hello,
>>
>> The context :
>> I'm using Axis2 1.0
>> I have a service defined in wsdl (see the attachement : upload.wsdl)
>> I call the operation initUpload.
>> When a javaException occurs in the method, I send a AxisFault build with
>> this method :
>>
>> public static AxisFault newErreurJava(Exception e) {
>> AxisFault ex = new AxisFault(e.toString(), new
>> QName(WsConstantes.NS_UPLOAD_SERVICE, "erreurJava"));
>>
>> // Extraction de la pile d'erreur
>> StringWriter sw = new StringWriter();
>> PrintWriter pw = new PrintWriter(sw);
>> e.printStackTrace(pw);
>> pw.close();
>>
>> // Création du détail
>> OMFactory factory = OMAbstractFactory.getOMFactory();
>> OMNamespace nsUpl =
>> factory.createOMNamespace(WsConstantes.NS_UPLOAD_TYPES, "upl");
>> OMElement detail = factory.createOMElement("javaException",
>> nsUpl);
>> factory.createOMElement("class", nsUpl,
>> detail).setText(e.getClass().getName());
>> factory.createOMElement("stack", nsUpl,
>> detail).setText(sw.toString());
>> ex.setDetail(detail);
>>
>> return ex;
>> }
>>
>> I naively thought that I would get a correct SOAP:Fault answer with
>> this. Instead, I get what is in response.xml
>>
>>
>> I have seen in org.apache.axis2.receivers.RawXMLINOutMessageReceiver
>>
>> public void invokeBusinessLogic(MessageContext msgContext,
>> MessageContext newmsgContext)
>> throws AxisFault {
>> try {
>>
>> /* .... */
>>
>> OMElement result;
>> try {
>> result = (OMElement) method.invoke(obj, args);
>> } catch (Exception e) {
>> throw new AxisFault(e.getMessage());
>> }
>>
>> /* ... */
>>
>> } catch (Exception e) {
>> throw AxisFault.makeFault(e);
>> }
>> }
>>
>> And in AxisFault :
>> public static AxisFault makeFault(Exception e) {
>> if (e instanceof InvocationTargetException) {
>> Throwable t = ((InvocationTargetException)
>> e).getTargetException();
>>
>> if (t instanceof Exception) {
>> e = (Exception) t;
>> }
>> }
>>
>> if (e instanceof AxisFault) {
>> return (AxisFault) e;
>> }
>>
>> return new AxisFault(e);
>> }
>>
>> It seams that the catch around the refective invokation kills the
>> InvocationTargetException that would be dealed by AxisFault.makeFault()
>> otherwise.
>>
>> But because Axis and webservices in general are new for me, I'm not sure
>> about it.
>>
>> What can I do to get a SOAP:Fault that is conform to my wsdl ?
>> Thank you !
>>
>> --
>> Jérôme Mainaud Klee Group
>> jmainaud@kleegroup.com <http://www.kleegroup.com/>
>> + 33 146 295 825 Tel: + 33 146 292 525
>> Fax: + 33 146 292 529
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: [Axis2] Howto send custom AxisFault that respect my WSDL ?
Posted by robert lazarski <ro...@gmail.com>.
Can you try the nightlies?
http://people.apache.org/dist/axis2/nightly/
If that does not work, please file a jira and upload your wsdl.
Robert
On 9/5/06, Jérôme Mainaud <jm...@kleegroup.com> wrote:
> Hello,
>
> The context :
> I'm using Axis2 1.0
> I have a service defined in wsdl (see the attachement : upload.wsdl)
> I call the operation initUpload.
> When a javaException occurs in the method, I send a AxisFault build with
> this method :
>
> public static AxisFault newErreurJava(Exception e) {
> AxisFault ex = new AxisFault(e.toString(), new
> QName(WsConstantes.NS_UPLOAD_SERVICE, "erreurJava"));
>
> // Extraction de la pile d'erreur
> StringWriter sw = new StringWriter();
> PrintWriter pw = new PrintWriter(sw);
> e.printStackTrace(pw);
> pw.close();
>
> // Création du détail
> OMFactory factory = OMAbstractFactory.getOMFactory();
> OMNamespace nsUpl =
> factory.createOMNamespace(WsConstantes.NS_UPLOAD_TYPES, "upl");
> OMElement detail = factory.createOMElement("javaException", nsUpl);
> factory.createOMElement("class", nsUpl,
> detail).setText(e.getClass().getName());
> factory.createOMElement("stack", nsUpl,
> detail).setText(sw.toString());
> ex.setDetail(detail);
>
> return ex;
> }
>
> I naively thought that I would get a correct SOAP:Fault answer with
> this. Instead, I get what is in response.xml
>
>
> I have seen in org.apache.axis2.receivers.RawXMLINOutMessageReceiver
>
> public void invokeBusinessLogic(MessageContext msgContext,
> MessageContext newmsgContext)
> throws AxisFault {
> try {
>
> /* .... */
>
> OMElement result;
> try {
> result = (OMElement) method.invoke(obj, args);
> } catch (Exception e) {
> throw new AxisFault(e.getMessage());
> }
>
> /* ... */
>
> } catch (Exception e) {
> throw AxisFault.makeFault(e);
> }
> }
>
> And in AxisFault :
> public static AxisFault makeFault(Exception e) {
> if (e instanceof InvocationTargetException) {
> Throwable t = ((InvocationTargetException)
> e).getTargetException();
>
> if (t instanceof Exception) {
> e = (Exception) t;
> }
> }
>
> if (e instanceof AxisFault) {
> return (AxisFault) e;
> }
>
> return new AxisFault(e);
> }
>
> It seams that the catch around the refective invokation kills the
> InvocationTargetException that would be dealed by AxisFault.makeFault()
> otherwise.
>
> But because Axis and webservices in general are new for me, I'm not sure
> about it.
>
> What can I do to get a SOAP:Fault that is conform to my wsdl ?
> Thank you !
>
> --
> Jérôme Mainaud Klee Group
> jmainaud@kleegroup.com <http://www.kleegroup.com/>
> + 33 146 295 825 Tel: + 33 146 292 525
> Fax: + 33 146 292 529
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org