You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Delanghe Stefaan <St...@c4j.be> on 2013/11/07 11:26:50 UTC
onException convertions to soapFault
Hey,
First i am new to Camel. Hope not for long. :)
A question regarding the exception arise for my current project.
When I catch a particular exception
onException(SocketTimeOutException.class)
How can I convert this exception to a soapfault?
Kind regards,
Stefaan
Re: onException convertions to soapFault
Posted by alapaka <al...@rocketmail.com>.
you can use setFaultBody:
<to uri="velocity:my/package/CreateSOAPFault.vm"/>
<setFaultBody><simple>${body}</simple></setFaultBody>
here is a simple velocity script to create the fault document:
<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>$exchange.EXCEPTION_CAUGHT</faultcode>
<faultstring>$exchange.getExchangeId()</faultstring>
</soap:Fault>
--
View this message in context: http://camel.465427.n5.nabble.com/onException-convertions-to-soapFault-tp5742775p5742797.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: onException convertions to soapFault
Posted by sdelanghe <st...@yandex.com>.
Thanks for the suggestion.
Is it possible to do this directly in the route (onException) , based on
thrown exception?
Can i avoid using the processor?
thnx
Stefaan
--
View this message in context: http://camel.465427.n5.nabble.com/onException-convertions-to-soapFault-tp5742775p5742788.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: onException convertions to soapFault
Posted by Willem jiang <wi...@gmail.com>.
You can use try()… catch() to build a SOAP fault like this
.doTry()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new IllegalStateException();
}
})
.doCatch(IllegalStateException.class).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// Create the SOAPFault here
UnknownPersonFault faultDetail = new UnknownPersonFault();
faultDetail.setPersonId("");
UnknownPersonFault fault = new UnknownPersonFault("Get the null value of person name", faultDetail);
exchange.getOut().setBody(fault);
exchange.getOut().setFault(true);
}
})
.end();
--
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Thursday, November 7, 2013 at 6:26 PM, Delanghe Stefaan wrote:
> Hey,
>
> First i am new to Camel. Hope not for long. :)
> A question regarding the exception arise for my current project.
>
> When I catch a particular exception
> onException(SocketTimeOutException.class)
>
> How can I convert this exception to a soapfault?
>
> Kind regards,
> Stefaan
Re: onException convertions to soapFault
Posted by Claus Ibsen <cl...@gmail.com>.
You can turn on handleFault on the route, then any exception thrown
will become a fault message.
On Thu, Nov 7, 2013 at 11:26 AM, Delanghe Stefaan
<St...@c4j.be> wrote:
> Hey,
>
> First i am new to Camel. Hope not for long. :)
> A question regarding the exception arise for my current project.
>
> When I catch a particular exception
> onException(SocketTimeOutException.class)
>
> How can I convert this exception to a soapfault?
>
> Kind regards,
> Stefaan
>
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen