我正在尝试向我的Silverlight客户端添加WCF端点行为。但是,我在运行时收到以下错误:
Unrecognized element 'behaviors' in service reference configuration.
Note that only a subset of the Windows Communication Foundation
configuration functionality is available in Silverlight.
WCF端点无法在Silverlight中扩展吗?下面列出了我的ServiceReferences.ClientConfig文件,显示了我如何尝试添加名为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>
答案 0 :(得分:0)
这不应该放在你的服务器端web.config吗? ServiceReferences.ClientConfig应包含与WebService参考信息有关的信息,例如:端点地址等。它包含服务的地址,并在编译生成的.xap文件中编译。
以下是我使用行为扩展的web.config示例:
<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>
这就是我所需要的。我的ServiceRefeferences.ClientConfig仅包含端点地址。它仅包含Windows Communication Foundation(WCF)客户端配置的子集。