Catching the SOAP Fault error in custom interceptor (Soap12FaultOutInterceptor)

前端 未结 3 1275
醉梦人生
醉梦人生 2021-02-10 09:52

I wrote a custom CXF interceptor to log all the SOAP request and responses into the database and it seems to be working fine with positive test cases and server errors.

3条回答
  •  佛祖请我去吃肉
    2021-02-10 10:25

    So in my custom interceptor I write the following code:

    Fault fault = new Fault(message.getContent(Exception.class));
    

    Now this is in some legacy code that was throwing exceptions from Java and letting the framework convert it to a fault. I won't get into my feelings on that, but this will get you the fault that is generated.

    Now if you are throwing a fault from your service method, do

    Fault fault = message.getContect(Fault.class);
    

    Hopefully this will help you get the answer to what you want. Make sure you register the interceptor like below

    
      
            
      
    
    

提交回复
热议问题