You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jason Royals <ca...@fragstealers.com> on 2008/11/28 01:38:07 UTC

How to raise SOAP faults?

Hi all,

Were using a CXF endpoint with Camel to expose SOAP proxies over some legacy
services.  One of our recent requirements is to analyse the response coming
back and if it matches some condition, we need to reply back with a SOAP
fault.

We're using the Spring DSL and I currently have something like this...

<route>
    <from uri="cxf:bean:someCxfEndpoint"/>
    ... transform to some legacy XML...
    <to uri="http://pox.endpoint/">
    <choice>
        <when>
             <xpath>//XYZ = 'some error condition'</xpath>
             <transform>
                 <groovy><![CDATA[
                     return
getClass().getResourceAsStream("META-INF/xml/canned-soap-fault.xml").text
                 ]]>
                   </groovy>
               </transform>
           </when>
           <otherwise>
                ... transform the valid response ...
           </otherwise>
       </choice>
</route>

This actually works nicely, but the HTTP response sent back from CXF is a
200, when SOAPFault needs to be 500.

I had a look at throwFault but it doesn't do what I need, because I don't
have an exception.  I guess all I need to do is somehow make CXF reply with
a HTTP status code of my choosing along with my canned soap fault, but it's
not obvious on how that's done with Camel.  Manually overriding the
http.responseCode header didn't work either.

Any ideas?

Thanks,
Jason
-- 
View this message in context: http://www.nabble.com/How-to-raise-SOAP-faults--tp20727483s22882p20727483.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to raise SOAP faults?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Jason

I just did a quick fix for your case[1].
Now you can set the repose code from the message's header.

out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new
Integer(500));

<setOutHeader headerName="org.apache.cxf.message.Message.RESPONSE_CODE">
   <simple>500</simple>
</setOutHeader>

Please check out the latest Camel 1.5.1-snapshot for verification.

[1]http://issues.apache.org/activemq/browse/CAMEL-1124

Willem


Jason Royals wrote:
> Hi all,
> 
> Were using a CXF endpoint with Camel to expose SOAP proxies over some legacy
> services.  One of our recent requirements is to analyse the response coming
> back and if it matches some condition, we need to reply back with a SOAP
> fault.
> 
> We're using the Spring DSL and I currently have something like this...
> 
> <route>
>     <from uri="cxf:bean:someCxfEndpoint"/>
>     ... transform to some legacy XML...
>     <to uri="http://pox.endpoint/">
>     <choice>
>         <when>
>              <xpath>//XYZ = 'some error condition'</xpath>
>              <transform>
>                  <groovy><![CDATA[
>                      return
> getClass().getResourceAsStream("META-INF/xml/canned-soap-fault.xml").text
>                  ]]>
>                    </groovy>
>                </transform>
>            </when>
>            <otherwise>
>                 ... transform the valid response ...
>            </otherwise>
>        </choice>
> </route>
> 
> This actually works nicely, but the HTTP response sent back from CXF is a
> 200, when SOAPFault needs to be 500.
> 
> I had a look at throwFault but it doesn't do what I need, because I don't
> have an exception.  I guess all I need to do is somehow make CXF reply with
> a HTTP status code of my choosing along with my canned soap fault, but it's
> not obvious on how that's done with Camel.  Manually overriding the
> http.responseCode header didn't work either.
> 
> Any ideas?
> 
> Thanks,
> Jason