Camel
  1. Camel
  2. CAMEL-3033

@WebFault interceptor to map exceptions to faults

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.0
    • Component/s: camel-cxf
    • Labels:
      None

      Description

      Like the HandleFaultInterceptor which turns fault -> exception, we should offer the reverse.

      The @WebFault is a standard annotation. The interceptor should then introspect the thrown exception and see if its annotated with @WebFault. If so it should turn the exception into a fault message.

      See nabble
      http://camel.465427.n5.nabble.com/CXF-consumer-fault-handling-tp2264078p2264078.html

      It should be possible to include in camel-core as annotations jars is optional.

        Issue Links

          Activity

          Hide
          Claus Ibsen added a comment -

          There is code in the nabble thread which shows how to do this. I am sure the reporter would gladly donate the code to Apache if requested to do so.

          Show
          Claus Ibsen added a comment - There is code in the nabble thread which shows how to do this. I am sure the reporter would gladly donate the code to Apache if requested to do so.
          Hide
          S. Ali Tokmen added a comment -

          I believe this feature is CXF-specific and will therefore not modify camel-core. Since the @WebFault is part of the JAX-WS 2.x spec, itself implemented by CXF, no extra JARs need to be included for camel-cxf.

          Show
          S. Ali Tokmen added a comment - I believe this feature is CXF-specific and will therefore not modify camel-core. Since the @WebFault is part of the JAX-WS 2.x spec, itself implemented by CXF, no extra JARs need to be included for camel-cxf.
          Hide
          S. Ali Tokmen added a comment -

          Attached patch that adds the functionality that enables CAMEL-CXF to generate an adequate SOAP Fault when the Exception thrown by a CAMEL exchange has a JAX-WS @WebFault annotation.

          The patch also adds in a test that checks that things keep on working great.

          I'm of course happily donating this code to Apache CAMEL.

          Show
          S. Ali Tokmen added a comment - Attached patch that adds the functionality that enables CAMEL-CXF to generate an adequate SOAP Fault when the Exception thrown by a CAMEL exchange has a JAX-WS @WebFault annotation. The patch also adds in a test that checks that things keep on working great. I'm of course happily donating this code to Apache CAMEL.
          Hide
          Willem Jiang added a comment -

          Hi Savas,

          I went through your patch, just few comments here.

          If you take a look at CXF FaultOutInterceptor and WebFaultOutInterceptor, you will find CXF already did that kind of thing for you.
          Such as setting the fault message with fault cause message , and building up the fault detail, all you need to do is make sure that
          your fault is thrown rightly from CxfConsumer.

          For the test part , you don't change anything the verification part of CXF test code, which means you patch didn't improve any thing.

          Can you write a small test case to demonstrate that current camel-cxf can't handle the fault rightly?

          Show
          Willem Jiang added a comment - Hi Savas, I went through your patch, just few comments here. If you take a look at CXF FaultOutInterceptor and WebFaultOutInterceptor, you will find CXF already did that kind of thing for you. Such as setting the fault message with fault cause message , and building up the fault detail, all you need to do is make sure that your fault is thrown rightly from CxfConsumer. For the test part , you don't change anything the verification part of CXF test code, which means you patch didn't improve any thing. Can you write a small test case to demonstrate that current camel-cxf can't handle the fault rightly?
          Hide
          S. Ali Tokmen added a comment - - edited

          Hello Willem

          You're right, I forgot to include the test in the patch! Now adding in a second patch file. Sorry. Should be better now

          If you try the test WITHOUT the patch on CxfConsumer.java, the test is supposed to fail: since the CXF default Fault generator does not parse the @WebFault annotations, the thrown Fault is a generic fault and the CXF client does not recognize it.

          Cheers

          Show
          S. Ali Tokmen added a comment - - edited Hello Willem You're right, I forgot to include the test in the patch! Now adding in a second patch file. Sorry. Should be better now If you try the test WITHOUT the patch on CxfConsumer.java, the test is supposed to fail: since the CXF default Fault generator does not parse the @WebFault annotations, the thrown Fault is a generic fault and the CXF client does not recognize it. Cheers
          Hide
          Willem Jiang added a comment -

          Hi Savas,

          Here is a thing for you new test case, as you are using HelloService which has no @WebService annotation, camel-cxf will use the simple front end instead of the JAXWS front end. The WebFaultOutInterceptor will not be a part of interceptor chain, so it make sense that it ignore the @WebFault annotation.

          Can you try to write a test which uses the Greeter interface?

          Show
          Willem Jiang added a comment - Hi Savas, Here is a thing for you new test case, as you are using HelloService which has no @WebService annotation, camel-cxf will use the simple front end instead of the JAXWS front end. The WebFaultOutInterceptor will not be a part of interceptor chain, so it make sense that it ignore the @WebFault annotation. Can you try to write a test which uses the Greeter interface?
          Hide
          S. Ali Tokmen added a comment -

          Hello Willem

          Of course you're right, this approach will also avoid touching test classes unnecessarily.

          Attaching new patch, with therefore only the modified CxfConsumer and the new test that uses org.apache.cxf.greeter_control.Greeter that throws an org.apache.cxf.greeter_control.PingMeFault.

          The test of course does not pass if you do not patch CxfConsumer.

          Cheers

          Show
          S. Ali Tokmen added a comment - Hello Willem Of course you're right, this approach will also avoid touching test classes unnecessarily. Attaching new patch, with therefore only the modified CxfConsumer and the new test that uses org.apache.cxf.greeter_control.Greeter that throws an org.apache.cxf.greeter_control.PingMeFault. The test of course does not pass if you do not patch CxfConsumer. Cheers
          Hide
          S. Ali Tokmen added a comment -

          Hello Willem

          I see you've assigned this issue to yourself, is it planned for CAMEL 2.5.0?

          Also, I guess updating the component to camel-cxf would be a good thing to do

          Cheers

          Show
          S. Ali Tokmen added a comment - Hello Willem I see you've assigned this issue to yourself, is it planned for CAMEL 2.5.0? Also, I guess updating the component to camel-cxf would be a good thing to do Cheers
          Hide
          Willem Jiang added a comment -

          Hi Savas

          I tried to apply your patch into the chunk, and did some improvement to fix the unit tests of camel-cxf.
          Now it should be fine, please check it out to verify with your application.

          Show
          Willem Jiang added a comment - Hi Savas I tried to apply your patch into the chunk, and did some improvement to fix the unit tests of camel-cxf. Now it should be fine, please check it out to verify with your application.
          Hide
          S. Ali Tokmen added a comment -

          Thank you Willem for the patch. Looks good on my side.

          A minor comment: can you please change the issue's component to camel-cxf? It still is camel-core, which is incorrect.

          Cheers

          Show
          S. Ali Tokmen added a comment - Thank you Willem for the patch. Looks good on my side. A minor comment: can you please change the issue's component to camel-cxf? It still is camel-core, which is incorrect. Cheers
          Hide
          Willem Jiang added a comment -

          @Savas,

          It's done

          Show
          Willem Jiang added a comment - @Savas, It's done
          Hide
          S. Ali Tokmen added a comment -

          Awesome

          Thank you

          Show
          S. Ali Tokmen added a comment - Awesome Thank you
          Hide
          Claus Ibsen added a comment -

          Closing all resolved tickets from 2010 or older

          Show
          Claus Ibsen added a comment - Closing all resolved tickets from 2010 or older

            People

            • Assignee:
              Willem Jiang
              Reporter:
              Claus Ibsen
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development