Tuesday, November 2, 2010

Continued

Step4:


Configuration
This configuration identifies the ErrorHandlerElement as a behavior extension, which then allows errorHandler (the name of the configured extension) to be defined against the service behavior. This is how the error handler gets hooked up for the service.

01<?xml version="1.0" encoding="utf-8" ?>
02<configuration>
03  
04  <system.web>
05    <compilation debug="true" />
06  </system.web>
07  
08  <system.serviceModel>
09    <behaviors>
10      <serviceBehaviors>
11        <behavior name="MyServiceBehavior">
12          <serviceDebug includeExceptionDetailInFaults="true" />
13          <errorHandler />
14        </behavior>
15      </serviceBehaviors>
16    </behaviors>
17    <extensions>
18      <behaviorExtensions>
19        <add name="errorHandler"
20            type="WcfServiceLibrary1.ErrorHandlerElement, WcfServiceLibrary1" />
21      </behaviorExtensions>
22    </extensions>
23    <services>
24      <service behaviorConfiguration="MyServiceBehavior"
25              name="WcfServiceLibrary1.Service1">
26        <endpoint binding="wsHttpBinding"
27                  contract="WcfServiceLibrary1.IService1" />
28      </service>
29    </services>
30  </system.serviceModel>
31</configuration>

This will hook up the error handler to cover any exceptions thrown by the service. Error handlers can also be debugged via the IDE.

No comments:

Post a Comment