<p>When coding web services, how do you structure your return values?  How do you handle error conditions (expected ones and unexpected ones)?  If you are returning something simple like an int, do you just return it, or embed it in a more complex object?  Do all of the web methods within one service return an instance of a single class, or do you create a custom return value class for each method?</p>

[{'answer_id': 39591, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 4, 'selected': True, 'text': '<p>I like the Request/Response object pattern, where you encapsulate your arguments into a single [Operation]Request class, which has simple public properties on it.</p>\n\n<p>Something like AddCustomerRequest, which would return AddCustomerResponse.</p>\n\n<p>The response can include information on the success/failure of the operation, any messages that might be used by the UI, possibly the ID of the customer that was added, for example.</p>\n\n<p>Another good pattern is to make these all derive from a simple IMessage interface, where your general end-point is something like Process(params IMessage[] messages)...  this way you can pass in multiple operations in the same web request.</p>\n'}, {'answer_id': 39603, 'author': 'joel.neely', 'author_id': 3525, 'author_profile': 'https://Stackoverflow.com/users/3525', 'pm_score': 1, 'selected': False, 'text': "<p>+1 for Ben's answer.</p>\n\n<p>In addition, I suggest considering that the generic response allow for multiple error/warning items, to allow the reply to be as comprehensive and actionable as possible. (Would you want to use a compiler that stopped after the first error message, or one that told you as much as possible?)</p>\n"}, {'answer_id': 39635, 'author': 'Ubiguchi', 'author_id': 2562, 'author_profile': 'https://Stackoverflow.com/users/2562', 'pm_score': 1, 'selected': False, 'text': '<p>If you\'re using SOAP web services then <a href="https://web.archive.org/web/20080906191515/https://www.w3schools.com/SOAP/soap_fault.asp" rel="nofollow noreferrer">SOAP faults</a> are the standard way to return error details, where the fault messages can return whatever additional detail you like.</p>\n'}, {'answer_id': 72251, 'author': 'Sixto Saez', 'author_id': 9711, 'author_profile': 'https://Stackoverflow.com/users/9711', 'pm_score': 0, 'selected': False, 'text': "<p>Soap faults are a standard practice where the calling application is a Soap client. There are cases, such as a COM client using XMLHTTP, where the Soap is parsed as XML and Soap faults cannot be easily handled. Can't vote yet but another +1 for @Ben Scheirman.</p>\n"}]
['https://Stackoverflow.com/questions/39585', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1219/']