I am trying to add a WCF endpoint behavior to my Silverlight client. However I am getting the following error at runtime:
Unrecognized element 'behaviors' in service reference configuration.
Note that only a subset of the Windows Communication Foundation
configuration functionality is available in Silverlight.
Is it really true that WCF endpoints cannot be extended in Silverlight? My ServiceReferences.ClientConfig file is listed below showing how I am trying to add an extention called MyBehaviorExtention:
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtentions>
<add
name="MyBehaviorExtention"
type="MyTest,
MyBehaviorExtention,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=null" />
</behaviorExtentions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="MyBehavior">
<MyBehaviorExtention />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding
name="MyWebServicePortBinding"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
name="MyWebServicePort"
address="http://localhost:8080/MyService"
binding="basicHttpBinding"
bindingConfiguration="MyWebServicePortBinding"
contract="MyServiceReference.MyWebService"
behaviorConfiguration="MyBehavior" />
</client>
</system.serviceModel>
</configuration>
Should this not go in your server side web.config instead? The ServiceReferences.ClientConfig should contain information pertaining to WebService Reference information e.g. endpoint address etc. It contains the addresses of the services and it gets compiled inside the .xap file generated by compilation.
Here is a sample of my web.config where I use behaviour extensions:
<extensions>
<behaviorExtensions>
<add name="silverlightFaults" type="MyApp.Web.Services.SilverlightFaultBehavior, MyApp.Web"/>
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="SilverlightFaultBehavior">
<silverlightFaults />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
This is all I need. My ServiceRefeferences.ClientConfig only contains endpoint addresses. It only contains a subset of Windows Communication Foundation (WCF) client configuration.