Well, instead you could return a PersonResponse wrapper object that would
have your Person as a property if the operation succeed. If it didn't, you
return a null in person property and an error code in an errorcode property.
This makes some sense, because you can then reserve the faults for generic
failures, such as your "database not available" or "service initialization
failure" cases which are likely to affect all of you web service operations.
Even in pure Java client/server, using fault handlers for these generic
error types makes IMHO more sense than trying to use faults for each
specific error case for a particular operation.

Kalle

On 11/21/06, Bill Burton <[EMAIL PROTECTED]> wrote:

Hello,

I've written a simple service that provides a way to lookup Person objects
by id or email address. The Person object just has some name and address
information. When a record is not found, I'm catching the runtime exception
from the Spring JDBC API, and rethrowing a checked exception which causes
XFire to generate a SOAP fault as follows:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema " xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>No record with id 000123005 was found by the
findById method!</faultstring>
         <detail>
            <RecordNotFoundException xmlns=" http://webservice.teds.pms"/>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

Right now, I'm just using the default generated bindings in my Spring
applicationContext.xml

    <bean name="PersonService" class="
org.codehaus.xfire.spring.ServiceBean">
        <property name="serviceBean" ref="PersonServiceImpl"/>
        <property name="serviceClass" value="
pms.teds.webservice.PersonService"/>
    </bean>

but plan to switch to Aegis to have better control over the mapping for
other reasons.

However, the person who's writing a C# .NET client to handle this
complains that it's hard to check for a fault whereas if I were to return an
error code and error text in my Person object, he would have no problem.  As
the Person object is supposed to be a reflection of the database columns, I
really don't want to change it in this manner.

What are the best practices for generating an error such as "record not
found" or "database not available" cases?

Thanks for any assistance,
-Bill
--
Bill Burton < bburton ayht mail daht com <[EMAIL PROTECTED]>>


Reply via email to