Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The key reason to separating internal business objects from the data contracts/message contracts is that you don't want internal changes to your app to necessarily change the service contract. If you're creating versioned web services (with more than 1 version of the implemented interfaces) then you often have a single version of your apps business objects with more than 1 version of the data contract/message contract objects.</p> <p>In addition, in complex Enterprise Integration situations you often have a canonical data format (Data and Message contracts) which is shared by a number of applications, which forces each application to map the canonical data format to its internal object model.</p> <p>If you want a tool to help with the nitty gritty of separating data contract/message contract etc. then check out Microsoft's Web Services Software Factory <a href="http://msdn.microsoft.com/en-us/library/cc487895.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/cc487895.aspx</a> which has some good recipes for solving the WCF plumbing.</p> <p>In regards to excpetions, WCF automatically wraps all exceptions in FaultExceptions, which are serialized as wire-format faults. </p> <p>It's also possible to throw generic Fault Exceptions which allows you to specify additional details to be included with the serialized fault. Since the faults thrown by a web service operation are part of its contract it's a good idea to declare the faults on the operation declaration:</p> <pre><code>[FaultContract(typeof(AuthenticationFault))] [FaultContract(typeof(AuthorizationFault))] StoreLocationResponse StoreLocation(StoreLocationRequest request); </code></pre> <p>Both the AuthenticationFault and AuthorizationFault types represent the additional details to be serialized and sent over the wire and can be thrown as follows:</p> <pre><code>throw new FaultException&lt;AuthenticationFault&gt;(new AuthenticationFault()); </code></pre> <p>If you want more details then shout; I've been living and breathing this stuff for so long I almost making a living doing it ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload