0 Replies Latest reply on Feb 18, 2010 11:15 AM by yqxu

    How to throw faults for reliable messaging web services (WS-RM)?

       

      Hi, I'm currenlty building a reliable messaging (WS-RM) web service. I want to return to the client a soap fault with customized messages when an exception occurs.

       

      Most of the documents online describe what a fault look like in the soap message but not on how it is implemented. Below is a snippet of what I have so far. I can get the TestFault to return without using reliable messaging, but once RM is turned on, I have no luck of getting the TestFault.

       

      @WebMethod (action="echoAction")

       

      public String echo(@WebParam(name="word") String word) throws TestFault{

       

       

                String response = "Hello "+word;    

                if (word.equals("fault"))

       

                throw new TestFault("It worked!");

       

       

           return response;

      }

       

      @WebFault

      public class TestFault extends Exception{

       

           private static final long serialVersionUID = 6118892030155347089L;

       

          

           public TestFault(String message) {

       

       

                super(message);

           }

       

      }

       

       

      Below is the fault I got when RM is turned on:

       

      <env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>

       

           <faultcode>env:Server</faultcode>

       

           <faultstring>RM handler have not serialized WS-RM message to the payload</faultstring>

       

      </env:Fault>

       

       

       

      Can someone please give me some pointers or code examples on how faults can be thrown properly once WS-RM is enabled? Thanks in advance.