1 Reply Latest reply on Jun 13, 2005 7:19 PM by jason.greene

    problem errorhandling

    elmtheolm

      hi,

      I have to implement a doc/lit-webservice (B2B) for our order-system. Our order-system is based on servlets, ejb-components
      and jboss4. On basis of this application-environment we decided to implement the webservice as an ejb service endpoint.


      To learn more about jbossws I created a little test-order-application (doing: xsd -> wsdl -> wscompile -> sessionbean -> delpoy).
      Everything works fine, but I have problems with the errorhandling of the webservice! How should I propagate errors
      (e.g. runtimeexceptions, businessruleexceptions) to the ws-client?

      Here are my tries:

      1. Try: Encapsulate all errors in the response message.

      Here's the code-fragment for the orderresponse:

      ...
      <xsd:complexType name="OrderResponse">
       <xsd:choice>
       <xsd:sequence>
       <xsd:element name="orderid" type="xsd:int"/>
       </xsd:sequence>
       <xsd:element name="error" type="xsd:string"/>
       </xsd:choice>
      </xsd:complexType>
      ...


      Problem: wscompile throws an error: xsd:choice not supported???


      2. Try: define one custom exception for the webservice: e.g. ServiceException and send these errors in a fault-message

      Problem: I never saw fault-elements in a commercial webservice-wsdl like from amazon (http://soap.amazon.com/schemas3/AmazonWebServices.wsdl)? How do such webservice propagate their exceptions (e.g. businessruleexceptions like "wrong bank account number format") to the user?


      How should I implement errorhandling for all exceptions for my "doc/lit-EJB Service Endpoint"?

      thanx elm

        • 1. Re: problem errorhandling
          jason.greene

          Faults were designed to convey exceptional conditions (errors), and thus they should be used for that. An error typically contains different information than a sucessful response message, so its always a good idea to use faults to your advantage.

          -Jason