c# - Throwing exceptions from .NET web service -
i have set of web services generated using [webmethod]
attribute. considered "good practice" throw argumentexception
such method if arguments aren't specified (and no sensible defaults used)? if so, should exception caught , re-thrown in order log both on server , client?
no, throwing exceptions web services not practice, .net exceptions (like argumentexception
) aren't supported cross platform (think of how java client need respond).
the standard mechanism indicating exceptions in web services soap fault.
with .asmx
, throwing soapexception generate fault you.
if move wcf, can @ faultcontracts.
for improved debugging of remote exceptions between .net client , .net server, cheat , send exception across wire using includeexceptiondetailinfaults in config. exception must serializable in order work. however, want turn off before system reaches production.
as aside, find if caller's soap request call poorly formed (e.g. if arguments include entities can't deserialized) webmethod
won't called @ - caller receive fault (often quite cryptic).
the above faults raised bad arguments client's call service should generated when call arguments validated.
possibly related - once request has passed validation, own internal system state assertion, use code contracts detect internal bugs (or possibly, missing validations should have happened earlier). these not propogated client.
Comments
Post a Comment