2 Replies Latest reply on Oct 7, 2005 11:14 AM by thewulf

    Throwing SoapFaults (no details)

    thewulf

      (running JBoss 4.0.3)

      For the last few days, I've been trying to figure out the proper way to throw a soap fault with details. I'm at the point where I can throw a soap fault from any exception, however none of them have details.

      I think I've narrowed it down to having to throw an AxisFault instead of just any exception and setting the details element -- which I'm currently figuring out as I don't normally use w3c dom objects (I prefer jdom).

      My question is: Is an AxisFault required to get the details element returned in the Soap Fault or is there an easier way?

      Thanks.

        • 1. Re: Throwing SoapFaults (no details)
          niwhsa

          Create a custom checked exception (sub class of java.lang.Exception) with all the properties you want. Throw this exception from your SEI methods. Wscompile should be able to handle this easily. I have done this and works great (even parent class properties get listed in the soap-fault tag is wsdl).

          Unless I misunderstood your question, the above should do the trick

          Example: In our code, we throw ExceptionA which extends project generic exception ExceptionB whihc in turn extends the java.lang.Exception.
          This is what is available in the wsdl file

           <complexType name="ExceptionA">
           <complexContent>
           <extension base="tns:ExceptionB">
           <sequence/></extension></complexContent></complexType>
           <complexType name="ExceptionB">
           <sequence>
           <element name="causeID" type="int"/>
           <element name="extendedMessage" type="string" nillable="true"/>
           <element name="logID" type="int"/>
           <element name="message" type="string" nillable="true"/></sequence>
           </complexType>
          


          As you can see casueID, extendedMessage, logID and message are properties of Exception B.

          • 2. Re: Throwing SoapFaults (no details)
            thewulf

            Thanks for the tips! The real problem was I was declaring "throws Throwable" instead of "throws MyException". I realized that when you said wscompile should have picked it up... it couldn't have picked it up if it wasn't declared.

            Thanks again.