Hypothetical situation that I wouldn't know exactly how to handle...
Posted on 2006-07-20
I was thinking the other day about how I would solve the following problem, but I just couldn't seem to come up with a really logical solution... or at least what I would think is a best practice. How would you handle the following?
Say I have winform client apps... any number of them. Lets say that this app has a couple web services. Okay, now lets say that one of the web service is like a broker web service... it also contains other web services. The client isn't aware of all the web services the broker service is hitting, the broker is responsible for knowing that. The point here is that we have a web service which may hit another web service, could be anything. Now, here's the hard part... getting all of the errors in case one happens. So client requests data from Service1. Service one then hits Service2, Service3 and Service4. Service3 errors out because the server that it's on is down. Service4 errors out because of a database issue or something. I want to return something back to the client listing all of the details of why the transaction failed (like in a log file or something), like
Success: Transaction to Service1 was successful
Success: Transaction to Service2 was successful
Error: Could not access Service3.
Error: Duplicate Primary Keys in Service4.
How do I handle this? Lets take it to another level and say that Service2 in itself might contain other services, so the transaction to Service2 was successful, but the transaction to Service2a failed for some reason.
The trick is keeping a single log file that contains all of the details on why various services failed, even if those service contain services which may have failed for some reason. What's the best way to handle something like this? I can't have every method return a bool if it passes or fails because it might already have a return value... So I can't just call GetData on Service2 and return a bool whether it passed or failed because it might already return a dataset... Does this make sense?
Keep in mind this is hypothetical, but I am just wondering what the best practice is in handling this type of scenerio.