Compartilhar via


Vista Beta 2 to Jun CTP Breaking Changes

The breaking changes for the

June CTP have now been

posted. Raw API changes are
here. This
is pretty significant because you won't see very many changes after these ones.

Here are the changes you are most likely to encounter when porting your apps

Base addresses are now supported in config for self-hosted services.

Before

<configuration>   <appSettings>     <add key="baseAddress"              value="https://localhost:8000/ServiceModelSamples/service" />   </appSettings>   <system.serviceModel>     <services>       <service name="Microsoft.ServiceModel.Samples.CalculatorService">         <endpoint address=""                         binding="wsHttpBinding"                         contract="Microsoft.ServiceModel.Samples.ICalculator" />        </service>     </services>   </system.serviceModel> </configuration>

//Code to create ServiceHost Uri uri = new Uri(ConfigurationManager.AppSettings["baseAddress"]); ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), uri);

After

<configuration>   <system.serviceModel>     <services>       <service name="Microsoft.ServiceModel.Samples.CalculatorService">         <host>           <baseAddresses>             <add baseAddress="https://localhost:8000/ServiceModelSamples/service"/>           </baseAddresses>         </host>         <endpoint address=""                         binding="wsHttpBinding"                         contract="Microsoft.ServiceModel.Samples.ICalculator" />        </service>     </services>   </system.serviceModel> </configuration>

//Code to create ServiceHost ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService));

Configuration of behaviors has changed:

Behaviors are now scoped by service or by endpoint under
system.serviceModel/behaviors/serviceBehaviors and system.serviceModel/behaviors/endpointBehaviors
respectively.  Further, the system.serviceModel/behaviors/behavior/@returnUnknownExceptionsAsFaults
has been replaced with system.serviceModel/behaviors/serviceBehaviors/serviceDebug/@includeExceptionDetailInFaults. 
This attribute controls whether exception detail is included in a fault that
occurs when a service encounters an unhandled exception.

Before

<behaviors>   <behavior name="MyServiceAndEndpointBehavior"                   returnUnknownExceptionsAsFaults="false">      <!-- behavior elements can implement IServiceBehavior or IEndpointBehavior-->   </behavior> </behaviors>

After

<behaviors>     <serviceBehaviors>         <behavior name="MyServiceBehavior">             <serviceDebug includeExceptionDetailInFaults="false" />             <!-- all behavior elements implement IServiceBehavior -->         </behavior>     </serviceBehaviors>     <endpointBehaviors>         <behavior name="MyEndpointBehavior">             <!-- all behavior elements implement IEndpointBehavior -->         </behavior>     </endpointBehaviors>  </behaviors>

Metadata is now off by default so for a service to expose
metadata, the ServiceMetadataBehavior must be configured on the service. When
this behavior is present, you can publish metadata by configuring an endpoint to
expose the IMetadataExchange contract.  The following configuration exposes a
mex endpoint at

https://localhost/servicemodelsamples/service.svc/mex and also enables wsdl
requests over HTTP GET at

https://localhost/servicemodelsamples/service.svc?wsdl.

<configuration>  <system.serviceModel>    <services>      <service name="Microsoft.ServiceModel.Samples.CalculatorService"                    behaviorConfiguration="CalculatorServiceBehavior">        <endpoint address=""                         binding="wsHttpBinding"                         contract="Microsoft.ServiceModel.Samples.ICalculator" />        <endpoint address="mex"                        binding="mexHttpBinding"                        contract="IMetadataExchange" />      </service>    </services>

    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->    <behaviors>      <serviceBehaviors>        <behavior name="CalculatorServiceBehavior">          <serviceMetadata httpGetEnabled="True"/>          <serviceDebug includeExceptionDetailInFaults="False" />        </behavior>      </serviceBehaviors>    </behaviors>  </system.serviceModel></configuration>

For client code updates, you should rerun svcutil.

Feel free to contact me, or ask questions on the WCF
forum.