I'm now toying around with WebServices, using the .NET framework (.asmx files, not WCF). I'm wondering what's the best practice to tell the user that some sort of business-error has happened in the method call.
My small test-case:
I have measuring probes which need to register with a central server. Each probe should have a different physical address. To register, they should call (via a web service):
[WebMethod]
public void RegisterReadingStation(out Guid sessionId, Int64 physicalAddress)
Now, the signature is not set in stone - actually, that's what I'm trying to figure out. :) I need to somehow alert the probe if it's trying to register itself using a physical address that's already taken.
The way I see it, I got a few possibilities:
Any thoughts about this?
I return a small class called ResultSet from each WebMethod, which contains an int errorcode and a string errormessage.
This gives you an easy check for error/success, and some details if things go wrong.
If the WebMethod needs to return data, I'll inherit from ResultSet to give a specific ResultSet to include the data as well.
I think the common concensus would be use a custom return code (integer). As long as the service documents what the possible return codes are, this should be feasible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With