You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bilalalp <sy...@gmail.com> on 2013/12/17 14:51:32 UTC
Soap Fault Unmarshal
Hi everyone, I have a problem about soap:fault. When i call a web service, it
returns a default soap fault message. In camel side, how can i convert it to
an object? Here is an example fault:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>My fault string...</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
--
View this message in context: http://camel.465427.n5.nabble.com/Soap-Fault-Unmarshal-tp5744949.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Soap Fault Unmarshal
Posted by bilalalp <sy...@gmail.com>.
Yes sure, I've changed the original names. When cxf:bean:myServiceEndpoint is
called for some conditions, it returns soap:fault message. I handle this
with checking whether the message contains faultstring or not. It's not a
good solution for me. How can i find out whether it has soap:fault or not
with camel? Is there a better way of doing this?
Also if there is a fault message, how can i marshall it to an object?
<camel:route id="myRoute" startupOrder="9">
<camel:from uri="direct:route1" />
<camel:doTry>
<camel:to uri="direct:route2" />
<camel:choice>
<camel:when>
<camel:simple resultType="java.lang.String">${property.destination}
== 'X'</camel:simple>
<camel:unmarshal>
<camel:soapjaxb contextPath="com.test.a.b"
elementNameStrategyRef="objectTypeStrategy" />
</camel:unmarshal>
<camel:bean ref="reservationProcessor" method="createReservation" />
<camel:bean ref="reservationProcessor" method="savePreRezervasyon" />
<camel:marshal>
<camel:soapjaxb contextPath="com.test.a.b"
elementNameStrategyRef="objectTypeStrategy" />
</camel:marshal>
</camel:when>
<camel:when>
<camel:simple resultType="java.lang.String">${property.destination}
== 'Y'</camel:simple>
<camel:to uri="cxf:bean:myServiceEndpoint" />
<camel:convertBodyTo type="java.lang.String" />
<camel:choice>
<camel:when>
<camel:simple>${in.body} contains 'faultcode' or ${in.body} contains
'faultstring'</camel:simple>
</camel:when>
<camel:otherwise>
<camel:unmarshal>
<camel:soapjaxb contextPath="com.test.a.b"
elementNameStrategyRef="objectTypeStrategy" />
</camel:unmarshal>
<camel:bean ref="reservationProcessor" method="savePreRezervasyon"
/>
<camel:marshal>
<camel:soapjaxb contextPath="com.test.a.b"
elementNameStrategyRef="objectTypeStrategy" />
</camel:marshal>
</camel:otherwise>
</camel:choice>
</camel:when>
</camel:choice>
<camel:doCatch>
<camel:exception>java.lang.Exception</camel:exception>
<camel:to uri="direct:handleException" />
</camel:doCatch>
</camel:doTry>
<camel:convertBodyTo type="java.lang.String" />
</camel:route>
--
View this message in context: http://camel.465427.n5.nabble.com/Soap-Fault-Unmarshal-tp5744949p5744983.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Soap Fault Unmarshal
Posted by Willem Jiang <wi...@gmail.com>.
Can you show me your camel route?
--
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
On December 18, 2013 at 3:48:04 PM, bilalalp (symen46@gmail.com) wrote:
>
> I'm using Spring DSL and I dont use ProducerTemplate. I have also
> catch block
> but i doesn't catch anything about webservice fault message.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Soap-Fault-Unmarshal-tp5744949p5744978.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Soap Fault Unmarshal
Posted by bilalalp <sy...@gmail.com>.
I'm using Spring DSL and I dont use ProducerTemplate. I have also catch block
but i doesn't catch anything about webservice fault message.
--
View this message in context: http://camel.465427.n5.nabble.com/Soap-Fault-Unmarshal-tp5744949p5744978.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Soap Fault Unmarshal
Posted by Willem Jiang <wi...@gmail.com>.
Camel will turn the Soap Fault message into an Exception.
I’m not sure how do you call the web service, but if you use ProducerTemplate[1] you can get an exception from the exchange just like this
Exception exception = exchange.getException();
If you have a camel route to call the service, you can handle the exception by using the ErrorHandler[2]
[1]http://camel.apache.org/producertemplate.html
[2]http://camel.apache.org/error-handler.html
--
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
On December 17, 2013 at 10:46:19 PM, bilalalp (symen46@gmail.com) wrote:
>
> Hi everyone, I have a problem about soap:fault. When i call a web
> service, it
> returns a default soap fault message. In camel side, how can i
> convert it to
> an object? Here is an example fault:
>
>
>
>
>
> soapenv:Server
> My fault string...
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Soap-Fault-Unmarshal-tp5744949.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>